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.
unix bash script
Name: jer Date: April 7, 2003 at 20:31:51 Pacific OS: linux-redhat CPU/Ram: dial into server
Comment:
I am attempting to write a script that takes positional parameter arguments and then uses them later.e.g.($ myselect.sh open read ...) What I do next is attempt use the eval function, but I do not understand how to evaluate back to the args. listed. here's some code. $ sh myselect.sh open read write close PS3="Enter choice: " x=0 choice=""
while true ; do for i in $@ ; do x=$(($x + 1)) echo "$x) $i" #this creates a menu list done echo $PS3 #diplay prompt read choice #get user input i=$choice #this is where it gets ugly eval $i #I want eval to determine which #arg. matches to choice var. echo "$choice ...$i" x=0 done
I figured out what I was doing wrong. Just in case anyone might care to know. Instead of assigning the read input to a var. named i, simply use following code to evaluate matching positional parameter #.
eval out=\$$choice
This line will match the value of the var. $choice to command line positional parameter variable. For e.g. user inputs 2 and that will make $choice == 2 but in code above eval will assign to the var. $out the string value of $2 == read
Summary: I'm new to unix and I'm writing a bash script that will prompt 5 command menu. I got stuck on the last two command that ask for the emalier with a subject & an attachment and the menu that's surrounde...
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...