go ahead... be a heretic | |
PerlMonks |
Re: Problem using Backtick having quotesby fizbin (Chaplain) |
on Oct 19, 2005 at 13:14 UTC ( [id://501290]=note: print w/replies, xml ) | Need Help?? |
The only thing I can think is that when you have quote marks the string as a whole contains "shell metacharacters", and when you don't, it doesn't. For example, see this bit from the documentation for perl's system command: If there is only one scalar argument, the argument is checked for shell metacharacters, and if there are any, the entire argument is passed to the system's command shell for parsing (this is "/bin/sh -c" on Unix platforms, but varies on other platforms). If there are no shell metacharacters in the argument, it is split into words and passed directly to "execvp", which is more efficient.So, for some reason, invoking "/bin/sh -c" is clearing the environment before running the command. I find this a bit odd, but you can check it with this simple perl script:
See if there's a difference in the two outputs. So then, the question is, why is this clearing the environment? It's not supposed to, but I wonder if on your system /bin/sh is aliased to csh. (or if perhaps the qx[] operator uses your default shell, which might be csh) Csh has a habit of always running its initialization scripts even if it's just being called for one command, and that could reset your environment variable settings. Fortunately, for java there is a simple solution - you can change your original code to: That is, use the -cp argument to set the classpath for java even when the environment is being reset.
--
In Section
Seekers of Perl Wisdom
|
|