c84032002 has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Expect; my $sftpPassword = "useracctPW"; open FTP_CARDS, "$ARGV[0]/sftp_CMS.cards" or die $!; # Uncomment the following line if you want to see what expect is doing # $Expect::Exp_Internal = 1; # Create the Expect object and create the message log file. my $params = " -oPort=10022 useracct\@sftp.section111.cms.hhs.gov"; my $command = "/usr/bin/sftp $params"; my $exp = Expect->spawn("$command") or die "Cannot spawn sftp command +\n"; $exp->timeout(600); ## [this does not append ]$exp->log_file("$ARGV[0]/sftp_CMS.log", "w") +; $exp->log_file("$ARGV[0]/sftp_CMS.log"); $exp->log_stdout(0); # Wait for Password prompt to show up then send it back $exp->expect(30, ["Password:"]); ## $exp->expect(30, ["useracct\@sftp.section111.cms.hhs.gov's password +:"]); $exp->send("$sftpPassword\n"); # Execute each sftp command found in the input file of commands while (my $ftp_command = <FTP_CARDS>) { # Wait for sftp prompt $exp->expect(600, ["sftp>"]); $exp->send("$ftp_command\n"); } # Destroy the expect object $exp->soft_close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: My Perl/Expect script aborts when sftp connection stalls at remote destination
by zow (Sexton) on Feb 24, 2010 at 19:24 UTC | |
by Anonymous Monk on Feb 24, 2010 at 19:52 UTC | |
by bobthebaritone (Sexton) on Feb 25, 2010 at 10:17 UTC | |
by salva (Canon) on Feb 25, 2010 at 15:09 UTC | |
by zow (Sexton) on Feb 25, 2010 at 19:26 UTC | |
|
Re: My Perl/Expect script aborts when sftp connection stalls at remote destination
by zentara (Cardinal) on Feb 25, 2010 at 14:11 UTC | |
by salva (Canon) on Feb 25, 2010 at 14:58 UTC |