[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Net::Telnet




> Simply stated, I want to use Net::Telnet to issue a command in a bash
> shell at a remote host.  However, to be able to do so, I need to put the
> file as one of the arguments to the command.  How would I go about this,
> i.e., copying the file from the source to the remote host so that I can
> execute the command with the file?

If $t is a live Net::Telnet connection, and $str is a simple string (no odd 
control characters included), this should do the trick.  

# Transfer $str into remote file $file

sub telnet_write_file {
    my ($file, $str) = @_;
    
    if ($str !~ /\n$/) { $str .= "\n"; }  # must end in \n
    $t->cmd("/bin/cat >$file\n$str\004") || die("Telnet command fails: $!");
}



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org