Operating System - HP-UX
1833077 Members
2618 Online
110049 Solutions
New Discussion

Expect - Rookie questions

 
SOLVED
Go to solution
Nick D'Angelo
Super Advisor

Expect - Rookie questions

I have downloaded what I need to use expect and compiled etc and it appears to be working just fine.

Now, my problem is actually trying to get it to work and use my required inputs to complete an ftp process.

My problem is this. We have made some network changes and I need to ftp to the proxy server first before going out to the 'outside' world.


My expect script looks like this:


spawn ftp (ip address of proxy server)
expect "User" ; send "username@destination site\n"
expect "Password: ; send "password\n"
expect "ftp>"
send " cd /directory\n"
expect "ftp>"
send " del oldfile.txt\n"
expect "ftp>"
send " rename file.txt file-old.txt\n"
expect "ftp>"
send " put newfile.txt\n"
expect "ftp>"
send "bye\n"

I have tested all these steps in sequence from the command line and it works perfectly, but from expect it bombs.

Any ideas?

I am on HPUX11i, ftping to a Windows Server I believe, but it shouldn't matter because it works from the command line, just not within expect.

Thanks
Always learning
3 REPLIES 3
Abdul Rahiman
Esteemed Contributor
Solution

Re: Expect - Rookie questions

Hi,

You have missed to pair a double quote (") on the third line after the string Password.
So, this would be the new line,
expect "Password:" ; send "password\n"

Of course, assuming that you have the correct prompt strings hardcoded in the script just as your windows ftp server would present for the username and password.

HTH,
Abdul.
No unix, no fun
Karthik S S
Honored Contributor

Re: Expect - Rookie questions

Try replacing all the "\n"s with "\r"s,

Ex:
spawn ftp (ip address of proxy server)
expect "User"
send "username@destination site\r"
expect "Password: "
send "password\r"
expect "ftp>"

-Karthik S S
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Nick D'Angelo
Super Advisor

Re: Expect - Rookie questions

All, I found this on my own yesterday after I actually read what my connection to the computer system was telling me - DOH !!

I was waiting for someone to reply to assign points, like i always try to.

Therefore, thank you and full points to both.

Nickd
Always learning