Hi Monks,

I'm using the Net::SSH2 library for specific reasons. If I wish to copy a file from a remote host to local client, I can use scp_get() but this function won't do directory copies (and certainly not recursive copy). So I need to check before copying if a file is a dir or symlink etc. In perl its easy with file test operators. But they don't work with files on a remote host!

So I'm trying to use Net::SSH2::SFTP->stat() on each file to determine it's type. I see it returns an argument 'mode' which usually gives me an integer 16877 for directories, and 33188 for regular files. All I can think is that these are codes of some sort relating to the permissions. But the docs are scant on this. If it really is the case that directories ALWAYS return this value, then I can use this as a file test operator, but I'm very hesitant to do this without checking on other systems.

Any suggestions would be greatly appreciated!
James


In reply to Net::SSH2::SFTP stat function by james_

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.