I_NEED_HELP Posted February 13, 2005 Report Share Posted February 13, 2005 I am practicing bash scripting and have created the following script which unfortunatly does not work. #!/bin/bash # # runssh - A Script to start and initialise either an ssh or sftp command # # Graham Hadgraft shopt -s -o nounset declare USERNAME # username e.g. u****** declare COMMAND # run ssh or sftp # Instructions printf "%s\n" "Press the number corresponding to the program you wish to use:" printf "%s\n" "1. SSH" printf "%s\n" "2. SFTP" # Main Script read -p "Enter your choice:" COMMAND read -p "Enter your username:" USERNAME if ["$COMMAND" = "1"]; then ssh -l $USERNAME ssh.ee.port.ac.uk fi if ["$COMMAND" = "2"]; then sftp $USERNAME@ssh.ee.port.ac.uk fi I am trying to make it so when i press 1 it runs the ssh command. However the if command does not seem to evaluate the contents of Command. Can anyone tell me what is wrong with this script. Quote Link to comment Share on other sites More sharing options...
sellis Posted February 14, 2005 Report Share Posted February 14, 2005 From "The Linux Pocket Guide" from O'Reilly... Remember that "[" is a command like any other, so it is followed by individual arguments separated by whitespace. Ensure that there is white space around both side of "[" and "]", like this: if [ "$COMMAND" = "1" ]; then That's your problem, or I'm a dutchman. 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.
Note: Your post will require moderator approval before it will be visible.