Re: Need help sending a password to ftp
From: kz (kz15_at_earthling.net)
Date: 03/02/04
- Next message: Anno Siegel: "Re: internationalization module"
- Previous message: joe: "Need help sending a password to ftp"
- In reply to: joe: "Need help sending a password to ftp"
- Next in thread: David Efflandt: "Re: Need help sending a password to ftp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 2 Mar 2004 16:25:53 +0100
"joe" <joez3@yahoo.com> wrote in message
news:5619c20c.0403020723.19151189@posting.google.com...
> I need to create a perl/expect script that will telnet into a system
> then bring up ftp on that system to transfer some files over there. I
> can get the telnet session open. I then start up ftp but that looks
> like it doesn't take my password. The script fails with:
> 331 Password required for moose .
> Password:
> 530 Login incorrect.
> Login failed.
> ftp> cd /tmp
> 530 Please login with USER and PASS.
>
> This is what my script looks like:
> #!/usr /bin/expect
> # Usage: "hold HOST USER PASS".
> # Action: login to node HOST as USER. Offer a shell prompt for
> # normal usage, and also print to the screen the word HELD
> # every five seconds, to exercise the connection periodically.
> # This is useful for testing and using WANs with short time-outs.
> # You can walk away from the keyboard, and never lose your
> # connection through a time-out.
> # WARNING: the security hazard of passing a password through the
> # command line makes this example only illustrative. Modify to
> # a particular security situation as appropriate.
> set hostname [lindex $argv 0]
> set username [lindex $argv 1]
> set password [lindex $argv 2]
> set server [lindex $argv 3]
>
> # There's trouble if $username's prompt is not set to "...} ".
> # A more sophisticated manager knows how to look for
> different
> # prompts on different hosts.
> set prompt_sequence "} "
>
> spawn telnet $hostname
>
> expect "login: "
> send "$username\r"
> expect "Password:"
> send "$password\r"
> # Some hosts don't inquire about TERM. That's another
> # complexification to consider before widespread use
> # of this application is practical.
> # Note use of global ? pattern matching to parse "*"
> # as a wildcard.
> expect -gl "TERM = (*)"
> send "\r"
> expect $prompt_sequence
> send "cd /opt/SUNWsymon/base/bin \r"
> expect $prompt_sequence
> send "ftp $hostname \r"
> expect "Name ($server:$username):"
> send "$username \r"
> expect -gl "331 Password required for*"
> expect -gl "Password:*"
> send "$password \r"
> expect "230 User $username logged in."
> expect "ftp>"
> send "cd /tmp \r"
> interact
What is precisely your Perl question?
Rgds,
Zoltan
- Next message: Anno Siegel: "Re: internationalization module"
- Previous message: joe: "Need help sending a password to ftp"
- In reply to: joe: "Need help sending a password to ftp"
- Next in thread: David Efflandt: "Re: Need help sending a password to ftp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|