Unix/Linux Go Back    


Shell Programming and Scripting 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

Shell Programming and Scripting


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

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-28-2006   -   Original Discussion by new2ss
new2ss's Unix or Linux Image
new2ss new2ss is offline
Registered User
 
Join Date: Jan 2006
Last Activity: 23 January 2014, 8:51 PM EST
Posts: 134
Thanks: 0
Thanked 0 Times in 0 Posts
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 ?
Sponsored Links
    #2  
Old Unix and Linux 06-28-2006   -   Original Discussion by new2ss
blowtorch's Unix or Linux Image
blowtorch blowtorch is offline Forum Advisor  
AFK
 
Join Date: Dec 2004
Last Activity: 1 July 2016, 6:18 AM EDT
Location: UK
Posts: 2,351
Thanks: 0
Thanked 6 Times in 6 Posts
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.
Sponsored Links
    #3  
Old Unix and Linux 06-28-2006   -   Original Discussion by new2ss
new2ss's Unix or Linux Image
new2ss new2ss is offline
Registered User
 
Join Date: Jan 2006
Last Activity: 23 January 2014, 8:51 PM EST
Posts: 134
Thanks: 0
Thanked 0 Times in 0 Posts
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..
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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
Return Status abhisheksunkari Shell Programming and Scripting 1 05-03-2011 05:17 AM
Return of EXIT status ( $? ) ZINGARO HP-UX 1 03-12-2008 07:07 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 09:14 PM.