Here is an expect script that will ssh automatically.  It can be
called by anything.  You can simply create the required send/expect in
the script.  You can also automate the creation of the expect with
autoexpect.
[root@localhost root]# more autossh
#!/usr/bin/expect

spawn ssh <hostname> -l <username> -F /root/.ssh/ssh_config

expect {
-re "password: " { send "<password>\r"}
}

interact {
}

NOTES: <> items you need to fill in yourself and of course, the path to your
ssh config can be anywhere.  Keep secure (like .autossh with 600 permission) cause
the password is in plain text.

expect is perfect for this kind of thing.

Another type of push commands to look at: rcp

Regards,

Kevin Mills

David Busby wrote:
Try using rsync, it might do what you need, will work over SSH or RSH.

/B


----- Original Message ----- 
From: "David Simmons" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 11, 2003 16:28
Subject: scripting an ssh session


  
We have a couple of servers that we want to push out periodic updates
to.  We want to automate this as much as possible.  

We have password-less ssh working (thanks to the group for that!).  So
using a shell script we can login in to a remote machine.  But that is
all we can do.  Once we login we are in a completely different shell
environment.  My script stops executing at that point.  Once I logout of
the remote server, my script continues running.

Is it possible to continue feeding commands from the ssh shell script I
wrote to the remote machine?  For example, if my script is something
like:

ssh [EMAIL PROTECTED]
cd /usr/local
echo "some new command" >> therefile
logout
exit 1

How can I get everything past the ssh command to run on the remote
machine?  Is it possible?

Thanks,

Dave Simmons



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list
    



  

Reply via email to