Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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 ideas...my 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
Sridhar

Comment on SCP return code 256
Download Code
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.

    -sam

Re: SCP return code 256
by Krambambuli (Deacon) 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
    Greetings,

    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.

    Cheers,
    Gyro

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://609440]
Approved by Joost
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2014-09-21 02:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (166 votes), past polls