james_ has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SSH2::SFTP stat function
by salva (Canon) on Oct 01, 2008 at 19:38 UTC | |
by james_ (Novice) on Oct 02, 2008 at 12:29 UTC | |
by salva (Canon) on Oct 02, 2008 at 12:47 UTC | |
by Anonymous Monk on Oct 02, 2008 at 13:25 UTC | |
|
Re: Net::SSH2::SFTP stat function
by zentara (Cardinal) on Oct 01, 2008 at 19:17 UTC | |
by james_ (Novice) on Oct 02, 2008 at 12:20 UTC |