in reply to Error checking on system SCP

That's an unsafe use of system. Using that syntax, system launches a shell to parse the command line string you're passing to system. That means you need to escape special characters $file and $target_host according to rules of whichever shell is used. But you can bypass the shell using the following syntax, since you don't use any features of the shell:

unless ( system( 'scp', $file, $target_host ) == 0 )

That might even solve your problem. I think the problem is that you're getting the return value of the shell that's executed to parse the command to execute instead of scp's. If you run scp directly, you'll get its error code.

Replies are listed 'Best First'.
Re^2: Error checking on system SCP
by rashley (Scribe) on Dec 14, 2005 at 19:22 UTC
    I've made the change you suggested, thanks.

    Unfortunately, it's still returning zero every time.

      Could it be that your scp doesn't return an error code?

      In Windows, I'd check it as following:

      >copy nul nul 1 file(s) copied. >if errorlevel 1 echo ** >copy bad args The system cannot find the file specified. >if errorlevel 1 echo ** **

      As you can see, copy returns an error code >= 1 when it fails. Does your scp do the same?