I am trying to send/receive files with a Unisys system over telnet/SSL via Zmodem. I am well aware that the year is 2007. Before I used expect and Kermit, but now I want this all to be clean inside perl. I handle the telnet/SSL with stunnel and that works great.


My System information:


This his how I handled the Zmodem in the expect script

#!/usr/local/bin/expect -f #!expect -f $1 $2 set hostid [lrange $argv 1 1] set retfil [lrange $argv 2 2] spawn kermit sleep .4 send -s -- "set protocol zmodem {rz -E} {rz -E} {sz --zmodem --delay-s +tartup 10 -e -w 2048 %s} {sz -a %s} {rz -E} {rz -E}\r" send -s -- "telnet $hostid\r" -exact " Do you want to send a file? Y/\[N\]: " { sleep .2 send -s -- "y\r" expect -exact " Enter an upload command to your mo +dem program now." sleep 5 send -s -- "\034\003" send -s -- "send $retfil\r" send -s -- "c\r" }


Here is where I am stuck with perl and all the searching hasn't helped me find a way to send a file via Zmodem.

#!/usr/bin/perl -w use strict; use Expect; my $exp = Expect->spawn("telnet remoteunisyssystem") or die "Cannot sp +awn telnet: $!\n";; $exp->log_file("testlog"); my $spawn_ok; my $timeout = 15; $exp->expect($timeout, [ qr'Do you want to send a file? Y/\[N\]: $', sub { my $fh = shift; print $fh "Y\n"; exp_continue; } ], [ 'Enter an upload command to your modem program now.', sub { my $fh = shift; print $fh "send somefilename\n"; exp_continue; } ], [ eof => sub { if ($spawn_ok) { die "ERROR: premature EOF in login.\n"; } else { die "ERROR: could not spawn telnet.\n"; } } ], [ timeout => sub { die "No login.\n"; } ], '-re', qr'[#>:] $', #' wait for shell prompt, then exit + expect );


In reply to Difficulty moving to perl from kermit expect by davesbedroom

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.