Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

System call scp error 256

by srchulo (Sexton)
on Dec 05, 2011 at 00:10 UTC ( #941777=perlquestion: print w/replies, xml ) Need Help??
srchulo has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I am running an scp command in my script to copy a file to a remote server. However, whenever I run it from a Perl script, I get a value of 256 returned and it does not work. Yet when I run the exact same command on the command line, I get a value of 0 returned and it works properly.

Does anyone have any idea what the issue could be? Here is the code that I am running:

my $result = `/usr/bin/perl /path/to/script/ file=1323036682.png remotehost=otherserver localpath=/tmp/ remotepath=/path/to/images`; is a script that just runs scp. Like I said, this exact command runs on command line, just does not work in Perl. I am working in a mod_perl environment if that helps at all.

Many thanks


Replies are listed 'Best First'.
Re: System call scp error 256
by roboticus (Chancellor) on Dec 05, 2011 at 00:17 UTC


    Usually the web server account has fewer permissions than a user account. Try running the script in a command line shell as the web server account to see what error message shows up. (Or just check the web logs.) Check directory permissions, environment variables, etc.


    When your only tool is a hammer, all problems look like your thumb.

      Thanks roboticus! It was a permissions error.

Re: System call scp error 256
by keszler (Priest) on Dec 05, 2011 at 00:53 UTC

    Does SCP return code 256 apply? If not, we'll likely need to see a listing of /path/to/script/