in reply to Re^4: System command silent screen
in thread System command silent screen
No, it isn't perfect. It invokes an unknown shell with unquoted arguments. That's begging for trouble.
If you want your script to play safe, fork() manually, then open /dev/null (or even better the return value of File::Spec->devnull()) as STDOUT and STDERR in the child process, then call exec() with a list of program name and arguments. In the parent process, wait() or waitpid() for the PID returned by fork().
This way, no shell is involved, and all of those nasty quoting problems are magically gone.
Of course, this requires more typing and more thinking. Alternatively, you can use one of the CPAN modules that wraps open(), fork(), exec(), waitpid(). Look at IPC::Run and IPC::Run3.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: System command silent screen
by ikegami (Patriarch) on Oct 10, 2010 at 21:20 UTC | |
by locked_user sundialsvc4 (Abbot) on Oct 11, 2010 at 13:31 UTC | |
by ikegami (Patriarch) on Oct 11, 2010 at 18:24 UTC | |
|
Re^6: System command silent screen
by chuckbutler (Monsignor) on Oct 10, 2010 at 23:52 UTC |