Solved

Perl Script Help

Posted on 2013-11-19
1
276 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 500 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
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 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.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

776 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