davesbedroom has asked for the wisdom of the Perl Monks concerning the following question:
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 );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Difficulty moving to perl from kermit expect
by jasonk (Parson) on Nov 18, 2007 at 19:40 UTC | |
by davesbedroom (Initiate) on Nov 18, 2007 at 21:00 UTC | |
by Anonymous Monk on Jul 24, 2008 at 22:52 UTC |