Sponsored Content
Full Discussion: Perl error checking question
Top Forums Shell Programming and Scripting Perl error checking question Post 302234841 by i9300 on Wednesday 10th of September 2008 01:39:16 PM
Old 09-10-2008
Perl error checking question

I am not very good with perl but trying to force myself to start learning...
I have a script that calls three other scripts in variables. I want to use a if statement to check the exit status and not sure how to do it..


This is basically what I have, the individual scripts print either a Y or N.
Code:
        $COMMAND1=`command1`;
        $COMMAND2=`command2`;
        $COMMAND3=`command3`;
        if ($COMMAND1 eq "N" || ($COMMAND2 eq "N" || ($COMMAND3 eq "N" ) {
                print "something here";
        } else {
                print "something else";
        }

This works, but I don't like it and it should be done with the exit status. I was reading up on this site....
Perl Special Variables

"$! When used in a numeric context, holds the current value of errno. If used in a string context, will hold the error string associated with errno.
$@ Holds the syntax error message, if any, from the last eval() function call."

I am just not sure how to implement it.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl data type checking

I am using perl 5.8.0. I need to check some values to see it they are floats. Our system does not have Data::Types so I can't use is_float. Is there something else that I can use? The only thing in Data is Dump.pm. I am not allowed to download anything to our system so I have to use what I have.... (3 Replies)
Discussion started by: ajgwin
3 Replies

2. Shell Programming and Scripting

Opening Files and checking contents in Perl

Hi All, I need some expert help in performing the following in Perl. I have a code below but it doesn;t seem to work. Can any expert give me some advice? Below are the requirements 1) Open numerous files assigned to an array @FILES. Note that the files are always named with the term... (7 Replies)
Discussion started by: Raynon
7 Replies

3. UNIX for Dummies Questions & Answers

perl scripting for checking if a process is running

Hi All, I am new to perl and have been trying to write a short script to check a process.Though i havent reached to the stage where i can match the output. I am trying to pass a variable x with value /opt/RGw/csbp-base/CSBP_BAT.01.00.05/csbp_BAT.01.00.05.jar and then pass another variable... (2 Replies)
Discussion started by: pistachio
2 Replies

4. Shell Programming and Scripting

checking the request for urls - perl

hi everybody . i'm trying to extract a bunch of urls from an http request but when i do that i get nothing . here it's my code use LWP::UserAgent; $url = "$ARGV"; $ua = LWP::UserAgent->new; $req = HTTP::Request->new(GET=>$url); $res = $ua->request($req); if... (0 Replies)
Discussion started by: KiD0
0 Replies

5. Programming

Error Checking

Hey guys i am facing a problem in my sql statement. I am trying to check if there is such a value in the database. Code: string NewMovie = "ww"; string queryText ; queryText = "Select * from movie_info WHERE movie_title = '"+ NewTitle +"'"; ... (1 Reply)
Discussion started by: gregarion
1 Replies

6. BSD

Question: OpenBSD command line for checking list of library used by daemon

Hi All, I would like to ask what is the command line on OpenBSD which able to be used to check the list of library which used by specific daemon? For example, I would like to check what are the libraries which are used by ftpd. Thank you in advance. Regards, Stefan (2 Replies)
Discussion started by: lcxpics
2 Replies

7. Shell Programming and Scripting

Need Suggestions to improve Perl script for checking malformed braces/brackets

Hi all, I've written a Perl script below that check and report for malformed braces. I have a UNIX ksh version and it took a couple of minutes to run on a 10000+ lines. With the Perl version it only took about 20 seconds so that is enough incentive for me to go Perl not to mention that I need... (1 Reply)
Discussion started by: newbie_01
1 Replies

8. Shell Programming and Scripting

checking co-presence of Var. - Shell or Perl

Hey fellas, I've posted this problem a few days back and I received just one post which was in PHP that I have no idea about! (Thanks to DGPickett) It would be so nice if you can help me with this in Shell or Perl. Here is the story: I have a big table with variables and observations. I... (9 Replies)
Discussion started by: @man
9 Replies

9. Shell Programming and Scripting

Question on sync 2 folders with checking files' modify date

Hi Linux Community I would like to ask about how to compare files in deferent server with date. Those A and B servers has the same folder, I have write a sample script to "ls" both folders and "diff" them, and then "rsync" the missing files. It was running well, both A and B are sync, until... (2 Replies)
Discussion started by: lunaticdawn
2 Replies

10. Shell Programming and Scripting

Checking the user input in perl for characters and length

My question is basically as the title says. How can I check a user inputted string is only certain characters long (for example, 3 characters long) and how do I check a user inputted string only contains certain characters (for example, it should only contain the characters 'u', 'a', 'g', and 'c')... (4 Replies)
Discussion started by: Eric1
4 Replies
Usage(3)						User Contributed Perl Documentation						  Usage(3)

NAME
pod2usage - print a usage message using a script's embedded pod documentation SYNOPSIS
use PDL::Pod::Usage; pod2usage(); pod2usage(2); pod2usage({EXIT => 2}); pod2usage({EXIT => 2, VERBOSE => 0}); pod2usage(EXIT => 1, VERBOSE => 2, OUTPUT=*STDERR); pod2usage(VERBOSE => 2); DESCRIPTION
pod2usage will print a usage message for the invoking script (using its embedded pod documentation) and then exit the script with the spec- ified exit value. It takes a single argument which is either a numeric value corresponding to the desired exit status (which defaults to 2), or a reference to a hash. If more than one argument is given then the entire argument list is assumed to be a hash. If a hash is sup- plied it should contain elements with one or more of the following keys: "EXIT" The desired exit status to pass to the exit() function. "VERBOSE" The desired level of "verboseness" to use when printing the usage message. If the corresponding value is 0, then only the "SYNOPSIS" section of the pod documentation is printed. If the corresponding value is 1, then the "SYNOPSIS" section, along with any section enti- tled "OPTIONS", "ARGUMENTS", or "OPTIONS AND ARGUMENTS" is printed. If the corresponding value is 2 or more then the entire manpage is printed. "OUTPUT" A reference to a filehandle, or the pathname of a file to which the usage message should be written. The default is "*STDERR" unless the exit value is less than 2 (in which case the default is "*STDOUT"). "INPUT" A reference to a filehandle, or the pathname of a file from which the invoking script's pod documentation should be read. It defaults to the file indicated by $0 ($PROGRAM_NAME for "use English;" users). If neither the exit value nor the verbose level is specified, then the default is to use an exit value of 2 with a verbose level of 0. If an exit value is specified but the verbose level is not, then the verbose level will default to 1 if the exit value is less than 2 and will default to 0 otherwise. If a verbose level is specified but an exit value is not, then the exit value will default to 2 if the verbose level is 0 and will default to 1 otherwise. EXAMPLE
Most scripts should print some type of usage message to STDERR when a command line syntax error is detected. They should also provide an option (usually "-h" or "-help") to print a (possibly more verbose) usage message to STDOUT. Some scripts may even wish to go so far as to provide a means of printing their complete documentation to STDOUT (perhaps by allowing a "-man" option). The following example uses pod2usage in combination with Getopt::Long to do all of these things: use PDL::Pod::Usage; use Getopt::Long; GetOptions("help", "man") || pod2usage(2); pod2usage(1) if ($opt_help); pod2usage(VERBOSE => 2) if ($opt_man); CAVEATS
By default, pod2usage() will use $0 as the path to the pod input file. Unfortunately, not all systems on which Perl runs will set $0 prop- erly (although if $0 isn't found, pod2usage() will search $ENV{PATH}). If this is the case for your system, you may need to explicitly specify the path to the pod docs for the invoking script using something similar to the following: o "pod2usage(EXIT => 2, INPUT => "/path/to/your/pod/docs");" AUTHOR
Brad Appleton <Brad_Appleton-GBDA001@email.mot.com> Based on code for Pod::Text::pod2text() written by Tom Christiansen <tchrist@mox.perl.com> perl v5.8.0 1999-12-09 Usage(3)
All times are GMT -4. The time now is 09:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy