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

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

bigtiny

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.

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").

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.