Visit Our UNIX and Linux User Community


Urgent help for perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Urgent help for perl script
# 1  
Old 12-14-2007
Bug Urgent help for perl script

I am having the autosys script for the perl as follows

#!/usr/bin/perl
print "Welcome to Autosys Ice Script\n";
print "Please enter the Environment (UAT PRD TRN ST DEV ALL):\n";
$environment = <STDIN>;
chomp($environment);
print "Please enter the Action (ON_ICE OFF_ICE):\n";
$action = <STDIN>;
#$action = "ON_ICE";
chomp($action);



if($environment eq "UAT")
{
$environment_symbol = U;
}
elsif($environment eq "PRD")
{
$environment_symbol = P;
}
elsif($environment eq "TRN")
{
$environment_symbol = T;
}
elsif($environment eq "ST")
{
$environment_symbol = S;
}
elsif($environment eq "DEV")
{
$environment_symbol = D;
}
elsif($environment eq "ALL")
{
$environment_symbol = "";
}
else
{
print "ERROR: Invalid Environment";
die();
}

system("rm autosys_list.txt");
#$command="ps -ef | grep $environment_symbol" ;
$command="autorep -J ALL | grep '^'$environment_symbol | awk '{print \$1}' > autosys_list.txt" ;
system($command);

open(MYINPUTFILE, "<autosys_list.txt");
while(<MYINPUTFILE>)
{
my($line) = $_;
chomp($line);
#print "$line\n";
if($line ne "")
{
if($action eq "ON_ICE")
{
put_job_on_ice($line);
}
elsif($action eq "OFF_ICE")
{
put_job_off_ice($line);
}
else
{
print "ERROR: Invalid Action";
die();
}
}
}

if($action eq "ON_ICE")
{
verify_jobs_on_ice();
}
elsif($action eq "OFF_ICE")
{
verify_jobs_off_ice();
}
else
{
print "ERROR: Invalid Action";
die();
}

sub put_job_on_ice
{
my $job_name = $_[0];
$kill_command="sendevent -E KILLJOB -J ".$job_name;
$ice_command="sendevent -E JOB_ON_ICE -J ".$job_name;
print "kill:".$kill_command."\n";
print "ice:".$ice_command."\n";
system($kill_command);
system($ice_command);
}

sub verify_jobs_on_ice
{
$command="autorep -J ALL | grep '^'$environment_symbol | egrep 'RU|AC'" ;
print "WARNING: The following jobs are still Running: (Make sure nothing is returned after this line)\n";
system($command);
}

sub verify_jobs_off_ice
{
$command="autorep -J ALL | grep '^'$environment_symbol | egrep 'OI'" ;
print "WARNING: The following jobs are still On Ice: (Make sure nothing is returned after this line)\n";
system($command);
}
sub put_job_off_ice
{
my $job_name = $_[0];
$ice_command="sendevent -E JOB_OFF_ICE -J ".$job_name;
print "action:".$ice_command."\n";
system($ice_command);
}


========================================

Note i want to find out that when i run the above script it should show me that the following autosys jobs are ON_ICE or OFF_ICE.

UAP_ADV_AribaReqDelMaint_B
UAP_ADV_BeginDay_B
UAP_ADV_AMDailyMaint_B
UAP_ADV_PMDailyMaint_B
UAP_ADV_LinkedJobs_B


Please help on urgent basis with detailed procedure

Thanks
samir

Previous Thread | Next Thread
Test Your Knowledge in Computers #460
Difficulty: Medium
The 64-bit timestamps used by NTP consist of a 32-bit part for seconds and a 32-bit part for fractional second.
True or False?

10 More Discussions You Might Find Interesting

1. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

2. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

3. Post Here to Contact Site Administrators and Moderators

Urgent: please replace the perl script in the post with following code

Hi This is very urgent as it is confidential info posted by mistake.Kindly help us asap. post link below: https://www.unix.com/shell-programming-and-scripting/201037-perl-while-loop-each.html please replace the perl script with following script in the post ... (1 Reply)
Discussion started by: ptappeta
1 Replies

4. UNIX for Dummies Questions & Answers

Uninstalled Perl - Need Urgent Help

Hey Guys, I'm hoping this is the right section.I am using a centos server. I was installing modules in perl when one got stuck in the installation and from there onwards I was having problems installing cpan modules using perl. I figured I'll reinstal perl (I SHOULDNT HAVE). So I went ahead... (2 Replies)
Discussion started by: zee3b
2 Replies

5. Shell Programming and Scripting

Need urgent help with PERL scripting

From the attached file I to need pick all rows that have AVG2 column value larger than 0.050, and write those values in to a separate file. Help me on how I pick the approp value & output them onto a file. Very Thanks in advance. :b: (5 Replies)
Discussion started by: tonystark
5 Replies

6. Shell Programming and Scripting

replace a string in perl - Urgent

Hi, Can anyone help me to replace ='is NOT NULL' to is NOT NULL in perl. I tried all the methods which i know, i didnt arrive at the solution. please help!! ---------- Post updated at 03:01 PM ---------- Previous update was at 02:56 PM ---------- I got it.......! Thanks, (1 Reply)
Discussion started by: jam_prasanna
1 Replies

7. Shell Programming and Scripting

it's urgent ! round number in perl scripting

my $number = 12.345673412 I need 3 digits after decimal or after dot(.) i mean , i need only 12.345 I used int(), ceil(), floor() but it gives me only 12 I need it. (10 Replies)
Discussion started by: pritish.sas
10 Replies

8. Shell Programming and Scripting

Perl script help URGENT???

Friends I generated a code too read a list if names from file and store it in array. The file contains names of some files. like a.txt b.txt c.txt ........ while I am running the script and gives a file name as argument I have to check wehere the file processed or not. if processed exit the... (4 Replies)
Discussion started by: jaganadh
4 Replies

9. Shell Programming and Scripting

Script Needed Urgent in shell or PERL!!!!!!!!!!!!!!!!!!!!

My I/p FIle #%npr # { { collectionBeginTime_Date 19Jul2007 granularityPeriod 900 NODEID BSC19 RLC_Raw_Blocksize_CS2 2048 START_DATE 19Jul07 measTimeStamp_Date 20Jul2007 COLLECTION_INTERVAL_MINS 15 RLC_User_Blocksize_CS2 1024 ... (1 Reply)
Discussion started by: aajan
1 Replies

10. Shell Programming and Scripting

Calling CGI Perl in Shell script [urgent]

All I want to call a perl program from my shell script. Please help me. I want to call through URL only. Like " http://www.test.com/CGI-bin/test?test=value" Please help to write this script. Thanx in advance. Thanking you Regards Deepak Xavier (0 Replies)
Discussion started by: DeepakXavier
0 Replies

Featured Tech Videos