I want a script that ssh to remote server and then run a script which is at my local machine and then store the output on my local machine
Expect script for ssh to remote server:
#!/usr/bin/expect -f
set Timeout 2
set IPaddress 10.118.137.78
set Username "username"
set Password "password"
spawn ssh $Username@$IPaddress
expect "ssword:"
send "$Password\r"
script to be run on remote machine and gather the data:
#!/bin/sh
for serveraddress in `cat list.out`
do
"seeisso $serveraddress | grep -E -i ' os |proddropdown'"
done >> getos
===
Not sure how to :
1. combine both and get the result.
2 in expect script it does not takes the \r and returns to newline.
Best Answer
Quick sample
That will work to execute the script on the remote side. I didn't toy with it too much but when it's done you have to Ctrl+C to exit expect. At this point I'd be setting up ssh keys for a small environment and for a larger use puppet or something to manage it then for even larger go for single sign-on probably kerberos.