I am trying to use the Expect module to connect to a SFTP site and download files and move them to a new folder. When I run this, instead of simply sending the command, it breaks it into 80 character segments and the command fails. I looked at the actual code of the expect module and it is hard coded to break commands into 80 character segments. If I manually login to the site and type out the 140 characters required the command works.
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>"]);
Here is the "print/send" sub in the Expect module:
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); } }

In reply to Why does Expect.pm break lines into 80 characters? by jmoore541

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.