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


Hi monks,

I'm trying to use the "Net::SFTP::Foreign::Compat" but when I use the "put" the boolean parameter "copy_time", it doesn't not working as the "Net::SFTP::Foreign" PUT command.

So, why I'm not use the PUT Net::SFTP::Foreign, is BC the ..Foreign::Compat PUT return me on status command the "SSH2_FX*" number values.
If ..Foreign::Compat can be return the "SSH2_FX*" number values will be great too!

Thank you very much Monks!!

Replies are listed 'Best First'.
More info, please.
by kyle (Abbot) on Jan 09, 2007 at 16:30 UTC

    Can you show us the code giving you the problem?

    I've looked briefly over documentation for Net::SFTP, Net::SFTP::Foreign, and Net::SFTP::Foreign::Compat, and I don't see anything about a copy_time parameter anywhere. Perhaps this is a code reference you've created for giving a status message?

    The docs for Net::SFTP and Net::SFTP::Foreign both say that their status method returns status codes similar to the one you mention ("SSH2_FX*"), so I wonder what problem you're having there too.

    Anyway, some more details would be helpful.

      Well, I use the Dev. release and the "status" method does not return more the numeric value of "SSH2_FX*" as the stable release.

      I made a switch case statement using the numeric return, but may I now need to get the status string and no more the numeric value, just to personalize the errors messages.

      Thank you very much!

        the return value for the status method is both a number and a string, it works in the same way as $!, so you can compare it numericaly if you wish.

        Anyway, for most high level methods such as put, get, etc., the status value doesn't really mean anything, it's just the server response to the last low level request. It is implementation dependant and could change between versions of the module. You will be better using the error method.

Re: Why SFTP copy_time doesn't work?
by jettero (Monsignor) on Jan 09, 2007 at 16:28 UTC
    That might just be a bug. Personally, I would ask the module maintainer. It may be an excellent opportunity to try out rt.cpan.org. Although, if I were you, I'd contact the author first (see Net::SFTP::Foreign::Compat). Mr. Fandiņo doesn't seem to have much traffic in there and he may not be using rt.cpan.org yet.

    On the other hand, he does say the API is "(mostly) compatible," not 100%. You know, stricly speaking, I don't see the copy_time param in Net::SFTP — that is apparently a Net::SFTP::Foreign argument only — nope, not in there either. Perhaps it's not even supposed to work?

    Let me ask you this: what does copy_time do?

    -Paul

      Hi Paul,

      The copy_time is the -P flag is specified on Put command in SFTP.

      So, actually I don't need to send access time file but the put command time.

Re: Why SFTP copy_time doesn't work?
by salva (Canon) on Jan 10, 2007 at 18:15 UTC
    You are trying to use Net::SFTP::Foreign::Compat put method as Net::SFTP::Foreign one, that's wrong, they have different arguments. Specifically, Net::SFTP::Foreign::Compat::put doesn't accept optional arguments as copy_time.

      Hi Salva,

      I used to the Foreign::Compat, but now I use the SFTP::Foreign again, just to use the "copy_time" params.

      And now I use the "status" for get the return of get,put, rename.. not using the numeric values more but the string message.

      Thank your for advicem, one more time ;o)

        As I already told you, status does return a numeric value. Use the numeric operators to handle it:
        unless ($sftp->put(...)) { if ($r == SSX_FX2_...) { # do whatever } }

        But most important, checking the status value is useless after calling put or any other high level method!!!, You should be using $sftp->error instead.