Computing.Net > Forums > Linux > Automating ssh login using expect

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Automating ssh login using expect

Reply to Message Icon

Name: vinsun
Date: November 10, 2007 at 18:41:37 Pacific
OS: LINUX
CPU/Ram: not sure
Product: not sure
Comment:

Hi All,
I am new to linux. I am trying to write a script to automate ssh login using expect utility. After I login to the remote host, I should be able to execute a set of commands.

Here's my script;

#!/usr/bin/expect
spawn username@hostname
expect "username@hostname's password:"
send "passwd"
interact
cd ~/customdir

The problem with this script is that it allows me to logon to the remote machine but it doesn't perform the 'cd' command.

What is it that i am doing wrong?

Any help is highly appreciated

Thanks,
vinsun




Sponsored Link
Ads by Google

Response Number 1
Name: linux_lover
Date: November 13, 2007 at 02:23:51 Pacific
Reply:

I think interact should be the last command.

use autoexpect utility ....



0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Automating ssh login using expect

Automatic login into remote linux system www.computing.net/answers/linux/automatic-login-into-remote-linux-system/30285.html

How to make Remote login using ssh, www.computing.net/answers/linux/how-to-make-remote-login-using-ssh/15422.html

ssh login slow www.computing.net/answers/linux/ssh-login-slow/15643.html