in reply to Re: Unable to grab STDERR from a backtick command
in thread Unable to grab STDERR from a backtick command
A little-known (and perhaps undocumented) feature of Perl is that a trailing "2>&1" on a command will be handled by Perl itself (not the shell) if there is no other reason to use a shell (if there are no other shell metacharacters in the given command string). (At least that was true quite a while ago when I was reading some of the Perl source code and I don't expect such a feature to be removed.)
So this problem would go away if the (useless) single quotes were removed from the example $cmd string. Yes, that "fix" likely won't work for the real problem.
I find it unfortunate that there is no way to trigger this feature when passing a list to system.
Update: Note that there are several modules to choose from that do "IPC" or "run commands" that can handle the "2>&1" for you. Or you can just handle it yourself using open (the 'fork' and 'dup' forms) and exec. Maybe I'll post an example of doing that in a reply, since I'd have to reread a few things to be able to write such.
- tye
|
|---|