Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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/

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://941777]
Approved by keszler
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-06-25 05:11 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.