Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

SCP return code 256

by mantra2006 (Hermit)
on Apr 11, 2007 at 18:40 UTC ( #609440=perlquestion: print w/replies, xml ) Need Help??
mantra2006 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I am using an SCP command to send a file to UK server. Its working
on the command prompt giving return code "0" where as
when I run through scheduler it returns me "256" as return
but the file successfully got scp'ed
...any code is below not enitre code just SCP
my $scpcp = "scp $rfilewithpath $destdir"; my $ret = system("$scpcp"); print STDERR "scp return code is $ret\n";
Thanks & Regards

Replies are listed 'Best First'.
Re: SCP return code 256
by samtregar (Abbot) on Apr 11, 2007 at 18:48 UTC
    To get the exit code from system() you must decode $?. From perldoc -f system:

    if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\ +n", ($? & 127), ($? & 128) ? ’with’ : ’without +’; } else { printf "child exited with value %d\n", $? >> 8; }

    In your case that means scp returned with exit code 1. According to the scp manpage that means it encountered an error, although it doesn't tell you what kind.


Re: SCP return code 256
by Krambambuli (Curate) on Apr 11, 2007 at 19:29 UTC
    Try maybe
    my $scpcp = "scp -v $rfilewithpath $destdir"; ...
    to get some debugging help and check STDOUT and STDERR afterwards. (You run this on a Unix or on a Windows platform ?...)

    What exactly do you mean by saying "... when I run through scheduler..." ? Might be that you already have the debugging info somewhere, just need to find where it is written/appended to ...?
Re: SCP return code 256
by Gyro (Monk) on Apr 11, 2007 at 21:10 UTC

    tilly had answered one like this back in 2001. Here is the node Re (tilly) 5: Seeking Feed back this was in response to a question on using scp Re: Re (tilly) 3: Seeking Feed back.

    If there is a difference in running by hand and running it from your scheduler, then it's possible a product your scheduler. We use cron, so I have to remember to include portions of my environment in my scripts.


Re: SCP return code 256
by salva (Abbot) on Apr 12, 2007 at 08:30 UTC
    That's probably the $PATH environment variable not being correctly set on your crontab

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2017-06-26 18:12 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (585 votes). Check out past polls.