Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
bash scripting
Name: mindman04 Date: October 25, 2004 at 22:16:58 Pacific OS: Windows XP SR2 CPU/Ram: Athlon 900
Comment:
I need to write a script in the Bash shell that asks for users to input number. The script needs to check to see if a non number was entered. Please help.
Name: thepubba Date: October 26, 2004 at 09:12:44 Pacific
Reply:
I don't do much bash. However, try this:
echo "Enter a number:" read NUM if [ "$(expr $NUM + 0 2> /dev/null)" = "$NUM" ] then echo "It's a Number" else echo "It's not a Number" fi
0
Response Number 2
Name: thepubba Date: October 26, 2004 at 09:35:58 Pacific
Reply:
Here is a better way to do it (it avoids external calls to expr and echo), but it doesn't work in bash (perhaps someone can explain why) but works fine in ksh:
#!/bin/ksh
print "Enter a number:"
read NUM
case $NUM in
+([0-9]) ) print "It's a number" ;; *) print "It's not a number" ;; esac
0
Response Number 3
Name: nails Date: October 27, 2004 at 10:31:37 Pacific
Reply:
Jerry:
In the bash shell, for a script like yours to work, the extended pattern matching has to be turned on. Place the following line in your script, and it works fine with bash:
Summary: Hello i have a script that sends printed info as an pdf document by mail, then i log this to a webpage. Now my problem is that i want to let my bash script know if the mail was sent, queued or defered...
Summary: I have converted a script from DOS to the BASH shell, and the script is perfoming some very strange things: Here is the script: #! /bin/bash # Being functions for scanmac.sh function helpFunction { ec...
Summary: I am trying to put ctrl-d in my bash script. (need to execute a command that needs ctrl-d to end the command). Does anywone know how to put it in the script ? I tried doing the following echo -e "\...