Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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
[1nickt]: folks, would you say that 1.0 is an integer ?
[Lady_Aleena]: 1nickt, I wouldn't, but I'm not normal.
LanX aggrees, LA isn't normal ;-P
[Lady_Aleena]: LanX, thanks bunches.
[Lady_Aleena]: Rigth now I'm ranting in my head about an old subject.
[1nickt]: Hm, that is, how to prevent Perl from turning 1.0 into 1? I feel sure this must be an faq, but am reading perlnum and not finding the answer ...
[Lady_Aleena]: 1nickt, why does it matter in this case?
[1nickt]: Hm, perhaps this? "Operators which expect an integer force the argument into the integer format."
[1nickt]: Can this be? So print
[1nickt]: ... "expects an integer" ?

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-05-24 18:31 GMT
Find Nodes?
    Voting Booth?