Solved

Perl Script Help

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

762 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

22 Experts available now in Live!

Get 1:1 Help Now