Run shell program in perl

Hello ,

I want to run some shell scripts in my perl script. I need to read the script's name from a file ( this file includes the name of all the scripts) and run the script one by one.. Please let me know how to go ..

Thanks in advance,
Radha

here is a basic script that reads lines from a file and tries to run the script:

open(S_FILE, '<', $filename)  or  die "Failed to read file $filename: $!";
while (my $line = <S_FILE>) {
    print "Going to run: $line \n";
    system("$line");
}
close(S_FILE);

modify this script as per your needs

Thanks Yogesh..

The main problem i m facing is that below line is not getting excuted.

system("$line");

I cannot see output of the line.. if i doing above. i have the script file in the same location.. the system displays the print statement above this. But nothing of the script. My script has only an echo statement.. but i cannot see this in the output..

Am i missing some other thing?

Also it says that the script is missing. But the file is present in the same folder...

I believe if you are not running the Perl script in the same directory that your shell scripts are located then you will need to specify that directory either in your file or in the line that executes them.

Thanks :slight_smile:

got the problem.. i need to mention the full path in each line of $filename.

Thanks again :slight_smile:
Radha