Forum Thread: Requested Help on My Bash Script Please!

Requested Help on My Bash Script Please!

Okay, so first of all, here is the Pastebin link.

I'm not sure why it is stopping the script completely after I type any number and press enter. For example, the title pops up, I press the indicated number for the program I wish to use then press enter. But when it should run nmap or hping, it just simply quits and goes back to the default terminal.

5 Responses

Have you tried running bash -x to see the debugging output?

Using PS3 works:

PS3='Enter a number:'
options=("nmap" "hping" "exit")
select opt in "${options@}"
do
case $opt in
"nmap" )
nmap
;;

"hping" )
hping
;;

"exit" )
clear
exit 0 ;;

esac
break
done

It then tells me

"./advancedportscan.sh: line 86: ${options@}: bad substitution" and I'm not for sure how to fix that. Also, thank you for your reply!

EDIT: Okay, so I have kindof fixed it. I deleted the @ character, and it worked, however...it only shows one option. and that's nmap. (option 1) and if I choose another number (i.e. 2) it just exits.

Ah - sorry, there are brackets in there that were apparently removed by the WonderHowTo auto-formatting. It should be:

"${options[@]}"

Ahhhhh, thank you so much! This helped me out a bunch!

Share Your Thoughts

  • Hot
  • Active