bluesplay106 has asked for the wisdom of the Perl Monks concerning the following question:

I want to be able to create a file handle from a file on a remote server. I've tried File::Remote, but I don't know how to include the port in its format. Can anyone help me?

Replies are listed 'Best First'.
Re: File Handle on a Server
by Loops (Curate) on Aug 02, 2013 at 20:37 UTC

    Disable strict mode and use bare filehandles File::Remote is too old to handle "my" variables. And then configure it to use ssh/scp as shown below:

    use strict; use warnings; use File::Remote; { no strict; my $remote = new File::Remote (rsh => "/usr/bin/ssh", rcp => "/usr +/bin/scp"); $remote->open(FILE, '>>biz:/tmp/weeeee') or die $!; print FILE "Here's a line that's added.\n"; $remote->close(FILE); }

    If you need to specify a non standard port, it's best to do it in your ssh config. For instance to configure the biz server used above for a different port:

    mkdir ~/.ssh echo "Host biz\nPort 888\n" >> ~/.ssh/config chmod go= ~/.ssh ~/.ssh/config
    HTH..