Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

sftp problem

by monk2b (Pilgrim)
on Aug 09, 2001 at 02:08 UTC ( #103250=perlquestion: print w/replies, xml ) Need Help??

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

I can not seem to get this script to retrieve any files any help would be greatly appreciated
#!/usr/local/bin/perl -w use strict use Net::SFTP; my $host = "somehost"; my $password = "somepasswd"; my $user = "someuser"; my $sftp = Net::SFTP->new($host,"user" => $user,"password" => $passwor +d); $sftp->get("/var/log/httpd/access_log");

When I do this
#!/usr/local/bin/perl -w use strict use Net::SFTP; my $host = "somehost"; my $password = "somepasswd"; my $user = "someuser"; my $sftp = Net::SFTP->new($host,"user" => $user,"password" => $passwor +d); print $sftp->get("/var/log/httpd/access_log"); <<<---|||

I do get the file at stdout. What am I doing wrong
learning monk2b

Replies are listed 'Best First'.
Re: sftp problem
by nardo (Friar) on Aug 09, 2001 at 02:23 UTC
    According to the Net::SFTP documentation:

    $local is optional. If not provided, the contents of the remote file $remote will be either discarded, if get is called in void context, or returned from get if called in a non-void context. Presumably, in the former case, you will use the callback function \&callback to "do something" with the contents of $remote.

    Your first example calls it in void context without providing a $local, thus nothing useful happens.
      Wow how easy was that. Thanks nardo
      learning mok2b

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://103250]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2022-06-30 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (98 votes). Check out past polls.

    Notices?