Run shell program in perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run shell program in perl
# 1  
Old 04-21-2008
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
# 2  
Old 04-21-2008
here is a basic script that reads lines from a file and tries to run the script:
Code:
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
# 3  
Old 04-21-2008
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?
# 4  
Old 04-21-2008
Also it says that the script is missing. But the file is present in the same folder...
# 5  
Old 04-21-2008
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.
# 6  
Old 04-21-2008
Bug

Thanks :-)

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

Thanks again :-)
Radha
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Converting shell to Perl I run into shell built in function trap and need alternative in Perl

I am working on converting shell to Perl script. In shell we have built in function trap Do you know alternative in Perl or actually we don't need it? Thanks for contribution (3 Replies)
Discussion started by: digioleg54
3 Replies

3. Shell Programming and Scripting

Perl program to run a Shell script issues...

Hi all, I have the following Perl script which is intended to run a Shell script and generate some logging for the purposes of tracking weather or not the script ran. I get an error, of course, since I don't know what I'm doing really. Here is the code: #!/opt/perl/bin/perl -w ... (14 Replies)
Discussion started by: zixzix01
14 Replies

4. Shell Programming and Scripting

Help to hide shell terminal and run prompt program after ssh login for specified user

Hey guys, I have some task from my office to lock user on the specified directory after the user logged on using ssh. And then run prompt program to fill the required information. Yeah, just like an ATM system. My question: How could I do those?? AFAIK I have to edit the ~./bashrc. But the... (1 Reply)
Discussion started by: franzramadhan
1 Replies

5. Shell Programming and Scripting

Shell script to run a python program on multiple entries in a file

Hello I am trying to run a python program using shell script, which takes a single argument from a file. This file has one entry per line : 1aaa 2bbb 3ccc 4ddd 5eee ... ... ... My shell script runs the program, only for the last entry : #!/bin/sh IFS=$'\n' for line in $(cat... (2 Replies)
Discussion started by: ad23
2 Replies

6. Shell Programming and Scripting

How to process and run a program in the background in perl?

Hi, I have a query about processing and running Perl program at the background. I have HTML file called Userform.html which accepts input from the user. As soon as input is given the contol goes to get.cgi (get.cgi does some processing and computing tasks). Actually get .cgi takes more... (0 Replies)
Discussion started by: vanitham
0 Replies

7. Shell Programming and Scripting

Run shell script from C program by calling fork and execl

I need to write a c program that uses the fork and excel system calls to run the shell script mode invoked like this: "./mode 644 ls -l" (that is the argumetns will always be 644 ls -l) here's the mode script: #!/bin/sh octal="$1" shift find . -maxdepth 1 -perm $octal -exec $@ {} \; ... (3 Replies)
Discussion started by: computethis
3 Replies

8. Shell Programming and Scripting

Can you run a unix script from a perl program

Hi all i have a unix script reformatter.sh i have a process whereby this script reformats a file before a perl program is used to update it i am having a little problem automating the entire process . is there a way whereby i can call the unix script from the perl program ? (12 Replies)
Discussion started by: dwightja24
12 Replies

9. Shell Programming and Scripting

want to run different files under the same program using shell script

suppose have different files 1.1 2.2 3.3 4.4 5.5 All the files have to run under the same command say tr -d '\n' so how to run all the files under the same command by using shell script (3 Replies)
Discussion started by: cdfd123
3 Replies

10. UNIX for Dummies Questions & Answers

how to run a shell command from C program?

Hi mates, i am trying to use the C execvp command to run a shell program like this: ..... char input ; printf("enter your command"); scanf("%ds",input) execvp input .... Compilation is ok but when i run it raise the error : Segmentation Error ... your help will be appreciated. ... (1 Reply)
Discussion started by: abdul
1 Replies
Login or Register to Ask a Question