• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Bash scripting help

Joined
Jan 3, 2006
Messages
580 (0.09/day)
Location
Manitoba, Canada
Processor Intel i7 3820 @ 4.3 Ghz
Motherboard Asus P9 x79 Pro
Cooling Fans 6x 120mm, 1x 140mm, 2x 200mm
Memory 16GB corsair dominator platinum DDR3 1866
Video Card(s) Asus GTX 670 DCII TOP 2GB
Storage 240GB Intel 330 SSD, 640 GB WD, 2 TB WD, 3 TB Segate GoFlex Desk USB 3.0
Display(s) Samsung 19inch widescreen
Case Coolermaster HAF XM
Audio Device(s) onbored
Power Supply pc power and cooling 750watt
Software Windows 7 SP1
Benchmark Scores 3D Mark 11 = P9951 http://www.3dmark.com/3dm11/4564568
So i'm trying to make a script that validates if the user input is a integer and it works but i don't know how loop the script if the input is invalid, like say they enter a "a" instead of a integer i need to be able to ask for a re-input. This is what i have so far...

#!/bin/sh
echo -n "Enter a integer: "
read x
if [ $x -eq $x 2> /dev/null ]
then
echo -e "$x is an integer"
else
echo -e "$x is not an integer"
fi
 
Joined
Jan 3, 2006
Messages
580 (0.09/day)
Location
Manitoba, Canada
Processor Intel i7 3820 @ 4.3 Ghz
Motherboard Asus P9 x79 Pro
Cooling Fans 6x 120mm, 1x 140mm, 2x 200mm
Memory 16GB corsair dominator platinum DDR3 1866
Video Card(s) Asus GTX 670 DCII TOP 2GB
Storage 240GB Intel 330 SSD, 640 GB WD, 2 TB WD, 3 TB Segate GoFlex Desk USB 3.0
Display(s) Samsung 19inch widescreen
Case Coolermaster HAF XM
Audio Device(s) onbored
Power Supply pc power and cooling 750watt
Software Windows 7 SP1
Benchmark Scores 3D Mark 11 = P9951 http://www.3dmark.com/3dm11/4564568
Well cancel that, figured it out after hours....
 

Arel3

New Member
Joined
Nov 7, 2010
Messages
39 (0.01/day)
If you run in to this problem again? Go in to the process manager of the server and kill the bash process. With the bash process turned off you can then run your tests on whatever you're working on without it getting bashed.
 
Top