jmoore541 has asked for the wisdom of the Perl Monks concerning the following question:
Here is the "print/send" sub in the Expect module:my $exp = Expect->spawn("sftp","username@host") or fatalmsg("$sender + Cannot spawn sftp command"); $exp->expect($timeout, ["Password Authentication"], ["Are you sure you want to continue connecting", sub {my $se +lf = shift; $self->send("yes\n");}] ); $exp->expect($timeout, ["password:"]); $exp->send('xxxxx'); $exp->expect($timeout, ["sftp>"]); my $cmd = "rename path/Long_Filename new_path/Long_Filename"; $exp->send("$cmd\n"); $exp->expect($timeout, ["sftp>"]);
sub print (@) { my ($self, @args) = @_; return if not defined $self->fileno(); # skip if closed if (${*$self}{exp_Exp_Internal}) { my $args = _make_readable(join('', @args)); cluck "Sending '$args' to ${*$self}{exp_Pty_Handle}\r\n"; } foreach my $arg (@args) { while (length($arg) > 80) { $self->SUPER::print(substr($arg, 0, 80)); $arg = substr($arg, 80); } $self->SUPER::print($arg); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why does Expect.pm break lines into 80 characters?
by nicomen (Novice) on Jan 12, 2016 at 15:53 UTC | |
by jmoore541 (Initiate) on Jan 12, 2016 at 18:26 UTC | |
|
Re: Why does Expect.pm break lines into 80 characters?
by salva (Canon) on Jan 13, 2016 at 07:31 UTC | |
|
Re: Why does Expect.pm break lines into 80 characters?
by eskiphill (Novice) on Jan 12, 2016 at 21:35 UTC | |
|
Re: Why does Expect.pm break lines into 80 characters?
by hotchiwawa (Scribe) on Jan 12, 2016 at 17:58 UTC |