LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Perl shell-out to script dunna work. Works on command line. Why? (http://www.linuxquestions.org/questions/linux-software-2/perl-shell-out-to-script-dunna-work-works-on-command-line-why-223351/)

jlangelier 08-27-2004 11:49 PM

Perl shell-out to script dunna work. Works on command line. Why?
 
I've got a perl script which executes:

my $retval = `sudo /usr/bin/firewall`;

... and comes back with a bunch of errors. First is:

/sbin/ipchains: host/network `-j' not found

If I run 'sudo /usr/bin/firewall' at the bash prompt, no problem. No errors.




This is the line in my bash script which works when launched at the command prompt, but not with launched perl backticks:

/sbin/ipchains -A input -i $LOOPBACK_INTERFACE -j ACCEPT


Any help greatly appreciated.

btmiller 08-28-2004 02:00 AM

My guess is that somewhere there's an environment variable or four that is set when you run in an interactive shell and is not set when you run as a shell script. An obvious first candidate is this $LOOPBACK_INTERFACE -- where is this variable set? Maybe print it out to be sure it's being set correctly. You can also try having Perl exec the script in debug mode (bash --debug <script>) and go through and examine the state of things to figure out where the problem is.


All times are GMT -5. The time now is 10:24 AM.