Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Verify scp return status

Tags
inappropriate ioctl for device, perl, perl shift, shell scripts, shift, shift perl

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 06-28-2006
Verify scp return status

Hi all

below is a snippet of my perl code
Code:
system ("scp -pq  $dest_file $path");

How i can i trap the return status? ie if the scp fails how can i know ?
# 2  
Old 06-28-2006
From the perl 5.8 man page:
HTML Code:
 The return value is the exit status of the program
             as returned by the "wait" call.  To get the actual
             exit value shift right by eight (see below).  See
             also "exec".  This is not what you want to use to
             capture the output from a command, for that you
             should use merely backticks or "qx//", as described
             in "`STRING`" in perlop.  Return value of -1
             indicates a failure to start the program (inspect $!
             for the reason).

             Like "exec", "system" allows you to lie to a program
             about its name if you use the "system PROGRAM LIST"
             syntax.  Again, see "exec".

             Because "system" and backticks block "SIGINT" and
             "SIGQUIT", killing the program they're running
             doesn't actually interrupt your program.

                 @args = ("command", "arg1", "arg2");
                 system(@args) == 0
                      or die "system @args failed: $?"

             You can check all the failure possibilities by
             inspecting $? like this:

                 $exit_value  = $? >> 8;
                 $signal_num  = $? & 127;
                 $dumped_core = $? & 128;

             or more portably by using the W*() calls of the
             POSIX extension; see perlport for more information.
Check the perlfunc man page for more details. The perlfunc man page can be accessed by setting the MANPATH to include the "<perl_install_dir>/man" directory.
# 3  
Old 06-28-2006
Hi,
does it mean i should do a
Code:
 if ($? = -1) print $! ;# to output error message
else print "success"

I tried the above and got something like " $! = inappropriate ioctl for device".
did i use $? wrongly?

Hi blowtorch, i amended my code, and it worked.thanks a lot
Code:
$exit_value  = $? >> 8;
if ($exit_value != 0) 
	{print "Sending of file NO\n";}
	else 
	{print "Sending of file DONE\n";}


Last edited by new2ss; 06-29-2006 at 12:29 AM..
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To verify status of particular Component(Siebel Server srvrmgr) vivek1489 Shell Programming and Scripting 2 07-27-2011 04:47 PM
nfs_stat_to_errno: bad nfs status return value: 88 general_lee Red Hat 2 06-21-2011 07:04 PM
Return Status abhisheksunkari Shell Programming and Scripting 1 05-03-2011 05:17 AM
opposite return status in c shell phil518 UNIX for Dummies Questions & Answers 5 01-13-2011 11:06 PM
command does not return exit status due to tee anand_bh Shell Programming and Scripting 2 12-05-2008 11:20 AM
evaluate return status of a function tig2810 Shell Programming and Scripting 4 07-06-2008 06:38 PM
Return of EXIT status ( $? ) ZINGARO HP-UX 1 03-12-2008 07:07 AM
Return status of all previous runs mpang_ Shell Programming and Scripting 4 06-27-2006 02:58 AM
return ftp status blt123 Shell Programming and Scripting 12 07-21-2005 05:48 AM
Return status... Shaz Shell Programming and Scripting 7 11-19-2002 05:35 AM


All times are GMT -4. The time now is 01:12 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password