Bash scripting question
Hi
i'm writing a bash script to scan a port of an IP and then prompt me to either scan another or exit, (basic i know but i have no scripting or programming knowlegde and i'm learning) i cant seem to get the script to prompt me to scan again or quit. can anyone tell me where i have gone wrong. below is my script. #!/bin/bash hpinger() { echo enter IP address read ip_address echo enter port read port hping $ip_address -c 1 -S -p $port >hpingscan } hpinger grep "flags=SA" /home/bash/bin/hpingscan > /dev/null 2>&1 if [ "$?" -eq 0 ]; then clear echo "port open" exit else echo "port closed" fi sleep 2 echo "1. another scan" echo "2. Exit" echo "Enter your choice: " read choice case $choice in 1) hpinger # call hpinger() function ;; 2) exit # exit esac Thanks for any help Thatch:confused: |
You don't see the menu because of the line in red -- your script quits, completely, if the port is open.
Code:
#!/bin/bash |
Thanks Dark Helmet, that fixed that one but then brought to light another problem with the script, but i'll work on that one myself.
many thanks Thatch |
All times are GMT -5. The time now is 05:48 PM. |