Results 1 to 4 of 4
Hi,
I am very new to bash scripting and after trying many different things I came to realize I need help
I need to come up with script to to ...
- 11-09-2009 #1Just Joined!
- Join Date
- Nov 2009
- Location
- Chicago
- Posts
- 7
Bash script to login via ssh
Hi,
I am very new to bash scripting and after trying many different things I came to realize I need help
I need to come up with script to to the following:
1) ssh -1 host -l uname
2) wait for password and echo the password
3) after successful login I need to run a command show int status which is a simple IOS command
Any help will appreciated.
Thank you.
- 11-10-2009 #2
SSH allows you to execute a command in the connection string, e.g.:
See man ssh for more details. If you need the console to wait before quitting in order to read the output:Code:$ssh host -l username <your_command_here>
Code:$ssh host -l username <your_command_here> && sleep 3
- 11-10-2009 #3Just Joined!
- Join Date
- Nov 2009
- Location
- Chicago
- Posts
- 7
Thanks for you post.
I need to login to a managed network switch first and then send a sequence of commands.
I tried you suggestion with command && sleep 3 && command2 but this will execute commands that are BASH not ios as I am logging in to the switch.
Any other ideas?
Thank you.
- 11-10-2009 #4Just Joined!
- Join Date
- Nov 2009
- Location
- Chicago
- Posts
- 7
This solved my problem:
ssh -1 host -l --pw kk >> /EOF
cmd1
cmd2
cmd3
EOF
cmdx executes sequentially.
Thanks everyone.


Reply With Quote