Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: Perl sftp behavior when there are no files in the share

by Bindo (Acolyte)
on Mar 27, 2013 at 08:39 UTC ( [id://1025648]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Perl sftp behavior when there are no files in the share
in thread Perl sftp behavior when there are no files in the share

Mr Soonix you are a life saver. It indeed did the trick :) thank you very much. And thanks all whoever have been trying to help.

I have one last question pertaining to this thread though. Could someone help me understand how to display the progress when a download is in place. I dont want to install another cspan module to reach this. IF I could just get the progress shown in the screen when you download a file manually is more than sufficient. I think what im asking here is how to print the STDOUT to the screen.Please try to help

  • Comment on Re^4: Perl sftp behavior when there are no files in the share

Replies are listed 'Best First'.
Re^5: Perl sftp behavior when there are no files in the share
by soonix (Canon) on Mar 27, 2013 at 14:47 UTC
    The docs for Net::SFTP::Foreign indicates that the get method accepts a callback.
    alternatively, on the call to Net::SFTP::Foreign->new you can set a file handle for stderr.

      Thank you very much again sir. Mr soonix beleive it or not Im a beginner in the world of perl. I too saw the context callback and I couldnt understand a thing. In fact net:sftp foreign is the firs ever cspan module I used in my scripting. Could you please be good enough to modify my code without complicating it too much (cos im a beginner :) so that I could grasp the idea of it? Please sir.

        This is untested, because I haven't yet figured out how to use cpan with the perl interpreter on my smartphone :-)

        First you need the callback routine, like this:

        sub show_progress { my($sftp, $data, $offset, $size) = @_; print "downloaded $offset of $size bytes\r"; }
        The \r positions the cursor to the beginning of the line, so that the next print overwrites it.

        Then you change

        $sftp->get($REM_FILE)
        to
        $sftp->get($REM_FILE, callback => \&show_progress)
        That should do the trick...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found