Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Perl Script Help

Posted on 2013-11-19
1
Medium Priority
?
303 Views
Last Modified: 2013-11-19
I need some help in writing a perl script, I know how to write scripts in Korn shell, So I need some help in transforming the korn shell logic to perl..

Step 1 : First I define a Runlist
Runlist : prescript.pl \
               configured.pl \
               postscript.pl\

Step 2: Then using For/While loop equivalent the scripts  in runlist should be executed one after other, The scripts are only run as root and only if they are successful the second one should be triggered

So can someone help me write this in Perl.

Thanks.
0
Comment
Question by:aanya247
1 Comment
 
LVL 31

Accepted Solution

by:
farzanj earned 2000 total points
ID: 39660473
Something like:

#!/usr/bin/perl

my @list = ('prescript.pl',  'configured.pl',  'postscript.pl');

foreach $f (@list)
{
    if ( system("./$f 2> /dev/null" ) != 0 )
    {
        die "File $f failed\n";
    }
}

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question