0

Hi,
I am creating script to execute a command.
for example my directory is /home/rana/script/
and then i want to execute ./abc.sh file from there
i am using following command
system("cd $output_directory") ;
system("./abc.sh");
where my output directory is /home/rana/script/
but i am unable to execute ./abc.sh clean build-all file
please help me out its very urgent

5
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by crb3
0

You definitely need to use 'chdir' and NOT the system call to 'cd'....

bigtiny

0

Hi,
You can obviously use path to your shell script run. Rather than changing the directory. `/path/to/your/script.sh` Hope this helps.

katharnakh.

0

Your code did what it was supposed to do, but it wasn't what you meant.

Your first system() instruction spawned a shell, which then executed your change-directory instruction. Then that shell ended. Your perl code, though, stayed where it was. Thus, when the second system() instruction spawned a shell, it started running right where the perl program was, and couldn't find that shell script to run.

If you need your perl program to end up in that directory, do like the others said and use the chdir() instruction. The simpler way, if you don't care where your Perl is running, is to concatenate those two shell commands together in one shell line with a semicolon so the same spawned bash shell executes both commands in order: system("cd /path/to/script;./scriptname").

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.