Sponsored Content
Full Discussion: Perl script not executing
Top Forums Shell Programming and Scripting Perl script not executing Post 302311508 by usha rao on Wednesday 29th of April 2009 12:45:59 AM
Old 04-29-2009
Question Perl script not executing

Hi All,
I have been given a perl script to modify but which is not running completely.And it is not showing any errors also.

The script is :

Code:
 
#!/usr/local/bin/perl
print "Which transaction? ";
print "\n";
print "1 - Inquiry";
print "\n";
print "2 - Delete Bank";
print "\n";
print "3 - Edit Bank";
print "\n";
print "4 - Enroll and Add Bank";
print "\n";
print "5 - Modify Default Bank";
print "\n";
print "6 - Submit Payment";
print "\n";
$goodChoice = "false";
while ($goodChoice eq "false") {
$choice = <STDIN>;
chomp $choice;
if ($choice eq "1") {
  $agent = "com.americanexpress.as.payment.app.agent.InquiryAgent";
  $goodChoice = "true";
}
elsif ($choice eq "2") {
  $agent = "com.americanexpress.as.payment.app.agent.DeleteBankAgent";
  $goodChoice = "true";
}
elsif ($choice eq "3") {
  $agent = "com.americanexpress.as.payment.app.agent.EditBankAgent";
  $goodChoice = "true";
}
elsif ($choice eq "4") {
  $agent = "com.americanexpress.as.payment.app.agent.EnrollAddBankAgent";
  $goodChoice = "true";
}
elsif ($choice eq "5") {
  $agent = "com.americanexpress.as.payment.app.agent.ModifyDefaultBankAgent";
  $goodChoice = "true";
}
elsif ($choice eq "6") {
  $agent = "com.americanexpress.as.payment.app.agent.SubmitPaymentAgent";
  $goodChoice = "true";
}
else {
  print "Please type a number, 1 - 6";
  print "\n";
}
}
$filename = "report.log";
open(FILEHANDLE, $filename);
$foundAgent = "false";
$printMetrics = "false";
while ($line = <FILEHANDLE>) {
  chomp $line;
  if ($printMetrics eq "true") {
    print $line;
    print "\n";
    $foundAgent = "false";
    $printMetrics = "false";
  }
  elsif ($foundAgent eq "true") {
    $printMetrics = "true";
  } 
  elsif ( $line =~ /$agent/ ) {
     $foundAgent = "true";
  } 
}
close (FILEHANDLE);



Can anyone please explain by what all is happening in this script.I am a beginner and couldn't understand all these commands.
Also i need to collect the output of this script in some output file.How to do that.


Thanks in advance.
U
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem executing setuid script in perl-5.8.6

Hi, I have a script (a.pl) that can be run by anyone. The script internally has to read a file and write into few files which are owned by user 'myUser'. Has to read the following file: -rwx------ 1 myuser myuser 4986 Aug 20 18:11 my.file Has to write into following files: ... (0 Replies)
Discussion started by: sarmakdvsr
0 Replies

2. Shell Programming and Scripting

Executing .profile from perl script

Hi, How can i execute .profile from a perl script I need this - i am trying to run perl script from crontab and it looses the environment variables Please provide help Your help is greatly appreciated Thanks (1 Reply)
Discussion started by: prekida
1 Replies

3. Programming

Date time problem while executing perl script.

Hi All, This Monday 15th March 2010, i have faced a weired issue with my Perl script execution, this script is scheduled to run at 1 minute past midnight on daily basis ( 00:01 EST ) generally for fetching previous business date , say if it is Monday it should give last Friday date, for Tuesday... (0 Replies)
Discussion started by: ravimishra
0 Replies

4. Shell Programming and Scripting

perl script to send an email executing with errors

Hello , i am using RHEL5 , i have got a perl script that executes and sends an email correctly if i run it with ./sendemail.sh command. This is the script below #! /usr/bin/perl use Net::SMTP; print "starting email send ."; $smtp = Net::SMTP->new("192.168.0.1");... (2 Replies)
Discussion started by: kabazzi
2 Replies

5. Shell Programming and Scripting

Executing AWK in a perl script using 'system'...

I have a simple perl script that looks similar to this: #!/usr/bin/perl/ # Have a lot of PERL code in the front of this script. #Would now like to execute a system command using AWK system (qq(cd /location && awk '/full/ {print $1;exit}' /myfile)); The system command in my perl script... (4 Replies)
Discussion started by: SysAdm2
4 Replies

6. Programming

Executing a awk command inside perl script --

Hello experts I want to execute a awk command, which reads from txt files and sums the numbers from the first column for those listed only inside a <init> block -- The awk command is like awk '/<\/?init>/{x = !x}x{a++}x && a > 2{sum+=$1}END{printf"%E" "\n", sum} So, I want to execute... (2 Replies)
Discussion started by: Alkass
2 Replies

7. Shell Programming and Scripting

Error in executing Perl script

Hello All I am facing an issue The unix script is running fine in unix environment which uses ssh connection but when I try to run the same in informatica environment (same server where I was running the unix script manually successfully) its showing the below error command-line line 0:... (11 Replies)
Discussion started by: Pratik4891
11 Replies

8. Shell Programming and Scripting

Problem executing perl script on remote server

Hello, I am running in to a problem running a perl script on a remote server. I can run a simple script test.pl which contains just a print statment without issue by running ssh root@1.2.3.4 perl test.pl However, I have a more complex script that does not execute as expected. I think I... (3 Replies)
Discussion started by: colinireland
3 Replies

9. Shell Programming and Scripting

executing perl script from another perl script : NOT WORKING

Hi Folks, I have 2 perl scripts and I need to execute 2nd perl script from the 1st perl script in WINDOWS. In the 1st perl script that I had, I am calling the 2nd script main.pl =========== print "This is my main script\n"; `perl C:\\Users\\sripathg\\Desktop\\scripts\\hi.pl`; ... (3 Replies)
Discussion started by: giridhar276
3 Replies

10. Shell Programming and Scripting

Help in executing select query from perl script

Hi, I have a perl snippet that call a select query with a bind variable,when i compile the script I'm unable to get the query output. The same query when i fire in sqlplus fetches few rows. The query takes bit time to fetch results in sqlplus. my $getaccts = $lda->prepare("select distinct ... (1 Reply)
Discussion started by: rkrish
1 Replies
PPERL(1p)						User Contributed Perl Documentation						 PPERL(1p)

NAME
PPerl - Make perl scripts persistent in memory SYNOPSIS
$ pperl foo.pl DESCRIPTION
This program turns ordinary perl scripts into long running daemons, making subsequent executions extremely fast. It forks several processes for each script, allowing many processes to call the script at once. It works a lot like SpeedyCGI, but is written a little differently. I didn't use the SpeedyCGI codebase, because I couldn't get it to compile, and needed something ASAP. The easiest way to use this is to change your shebang line from: #!/usr/bin/perl -w To use pperl instead: #!/usr/bin/pperl -w WARNINGS
Like other persistent environments, this one has problems with things like BEGIN blocks, global variables, etc. So beware, and try checking the mod_perl guide at http://perl.apache.org/guide/ for lots of information that applies to many persistent perl environments. Parameters $ pperl <perl params> -- <pperl params> scriptname <script params> The perl params are sent to the perl binary the first time it is started up. See perlrun for details. The pperl params control how pperl works. Try -h for an overview. The script params are passed to the script on every invocation. The script also gets any current environment variables, the current working directory, and everything on STDIN. Killing In order to kill a currently running PPerl process, use: pperl -- -k <scriptname> You need to make sure the path to the script is the same as when it was invoked. Alternatively look for a .pid file for the script in your tmp directory, and kill (with SIGINT) the process with that PID. ENVIRONMENT
pperl uses the PPERL_TMP_PATH environment variable to determine the directory where to store the files used for inter-process communication. By default, the subdirectory .pperl of the user's home directory is used. BUGS
The process does not reload when the script or modules change. $^S is not represented identically with respect to perl, since your script will be run within an eval block AUTHOR
Matt Sergeant, matt@sergeant.org. Copyright 2001 MessageLabs Ltd. SEE ALSO
perl. perlrun. perl v5.14.2 2011-11-15 PPERL(1p)
All times are GMT -4. The time now is 08:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy