Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-06-27 11:47 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (88 votes). Check out past polls.