|Don't ask to ask, just ask|
Re^3: best practices for checking system return values for piped commands?by Anonymous Monk
|on Apr 08, 2009 at 07:33 UTC||Need Help??|
I'm struggling with trying to identify a failure in a set of piped commands run on a remote host via ssh. I use perl to build and run the command line as below
Initially I just redirected the output to a file, which is fine if both the $TARGET_DIR and $TARGET_FILE exists. However, if one or both do not exist, then I still get a file created, but it's empty.
Things I've tried:
With $ret=system($cmd); and testing the the value of $ret:
With @results = `$cmd`, and testing the value of $?:
Using the @results approach, I only get one entry, so I suspect that the backtick method only sees one stream?
Any ideas on how I can detect the remote pipeline failure?