Teen Programmers Unite  


Return to forum top

making perl play nice with bash

Posted by infryq [send private reply] at July 26, 2002, 06:49:37 AM

Okay -- it's not difficult running a perl script from a shell(bash) script. But I'm having problems running a shell script from perl, mostly because I don't know perl very well and have been using the "slap it around until it works" method of coding.

What I want to do is run a bash script that takes two arguments, whose values I'm getting from elsewhere in the perl script.

Generally, to run a shell command from perl, you'd use

 use Shell qw(nameOfCommand); 
. Problems with this: I can't input "./nameofscript" because that looks like an incomplete search pattern. Also,
use Shell 
runs commands out of zsh, and I need bash. I had hoped that something like this:
 use Shell(bash);
bash("./nameofscript $arg1 $arg2"); 

might run the script from bash from inside zsh, but no such luck, I get a No Such File. Any perl afficionados out there have a suggestion? Can I change the default shell perl uses? Would it be easiest to just figure out the darn shell script in zsh-ese? Should I just swap control over to the shell script and run the perl one out of there?
Posted by unknown_lamer [send private reply] at July 26, 2002, 02:45:32 PM

Try system ("./script.sh"); (worked for me)

Posted by infryq [send private reply] at July 26, 2002, 04:43:47 PM


Posted by Zandalf [send private reply] at July 26, 2002, 06:41:27 PM

and she continued to program until the pretty birds outside her window told her it was 5:30am...

I love late night programming sessions ^_^

Posted by regretfuldaydreamer [send private reply] at August 01, 2002, 11:02:45 AM

Me too, I can only write good code from around midnight. I just get distracted before then.

You must be logged in to post messages and see which you have already read.

Log on
Save for later automatic logon

Register as a new user
Copyright TPU 2002. See the Credits and About TPU for more information.