Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Perl and SSH and ftp/scp

by hakkr (Chaplain)
on Jun 26, 2002 at 09:36 UTC ( #177342=perlquestion: print w/ replies, xml ) Need Help??
hakkr has asked for the wisdom of the Perl Monks concerning the following question:

I have found the Net::SSH module. How do I use it to secure copy files from from my server. Is it just a matter of logging in and issuing some remote cp command. If this is not possible can I use this module with Net::Ftp to achieve secure ftp tunneling. Is there maybe a Net::SFTP ? thanks

Comment on Perl and SSH and ftp/scp
Re: Perl and SSH and ftp/scp
by ariels (Curate) on Jun 26, 2002 at 09:40 UTC
    CPAN also has a module Net::SFTP, which might be more suited to your needs. (I've not used it, so I cannot comment further.)
Re: Perl and SSH and ftp/scp
by Kanji (Parson) on Jun 26, 2002 at 09:43 UTC
Re: Perl and SSH and ftp/scp
by grantm (Parson) on Jun 26, 2002 at 11:20 UTC

    I haven't had much luck with the SSH modules on platforms other than Linux, but this sort of thing is fairly portable:

        system("scp file host:file")

    (I use pscp from the putty package on Windows).

Re: Perl and SSH and ftp/scp
by Aristotle (Chancellor) on Jun 26, 2002 at 17:13 UTC

    Untested dirty hack ahead.

    use warnings; use strict; use Net::SSH qw(sshopen2); my $user = "username"; my $host = "hostname"; my $localfile = "~/example.local"; my $remotefile = "~/example.remote"; sshopen2("$user\@$host", *READER, *WRITER, "cat > $remotefile") || die + "ssh: $!"; open INFILE, "<", $localfile; print WRITER $_ while sysread INFILE, $_, 8192; close(INFILE); close(READER); close(WRITER);
    Use scp or Net::SFTP instead.

    Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://177342]
Approved by rob_au
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-08-02 06:01 GMT
Find Nodes?
    Voting Booth?

    Who would be the most fun to work for?

    Results (55 votes), past polls