Subspace3 Posted February 19, 2014 Share Posted February 19, 2014 (edited) Hi all, Yes I know I'm lame, its been such a long time since I've done any kind of scripting, I'm a cisco kid now. Wondering if any one can help me. echo -n Enter BSSID: read name echo $name >> /tmp/blacklist.txt Basically wanting that to run multiple times and then move on when the user is finished entering. I know I could just send the values as arguments when running the script (script.sh arg1 arg2 ect( but this way is much nicer. I'm thinking something like a while loop reading $name and if say "exit" comes up breaking the loop, but not sure on the syntax or if this is the best way as 'exit' would appear in the file also. thanks for any help Edited February 19, 2014 by Subspace3 Quote Link to comment Share on other sites More sharing options...
Sebkinne Posted February 19, 2014 Share Posted February 19, 2014 Sure! It's pretty simple, just an endless while look with an if statement checking the name variable which breaks it out of the loop. #!/bin/bash while true; do echo -n Enter BSSID: read name [[ "$name" == "exit" ]] && { echo Exiting. break } || { echo $name >> /tmp/blacklist.txt name="" } done Best Regards, Sebkinne Quote Link to comment Share on other sites More sharing options...
Subspace3 Posted February 20, 2014 Author Share Posted February 20, 2014 Awesome, thanks Sebkinne. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.