Solved

Perl Script Help

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Assess most serious Linux privilege escalation bug 17 149
Which Linux flavors will this run on? 6 76
nagios alerts 3 33
how to rebuild XFS volume from LV 19 38
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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.:

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now