Solved

Convert Korn shell echo status to Perl

Posted on 2008-11-02
5
448 Views
Last Modified: 2010-05-18
I have the following two UNIX Korn shell commands. The semi-colon is needed instead of the pipe symbol after the grep statement otherwise it doesn't work:

chk_auto_up | grep AUTOSYSDB; echo $?
it returns a 0

chk_auto_up | grep AUTOSYSDB2; echo $?
it returns a 1

Both of these shell statements are returning the correct echo status.

When I run this command as Perl:
system("chk_auto_up | grep AUTOSYSDB | echo $?");
or
system("chk_auto_up | grep AUTOSYSDB2 | echo $?");

they both return a 0

The "chk_auto_up" command is an AutoSys command which checks databases.

thanks
0
Comment
Question by:rkckjk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 22860745
system("chk_auto_up | grep AUTOSYSDB2 | echo $?")

should be

system("chk_auto_up | grep AUTOSYSDB2 ; echo $?")
0
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 22860752
Sorry, I didn't test beforehand.

You could do
my $result = `chk_auto_up | grep AUTOSYSDB2`;
 
if ($result) {
  print "Exists\n";
}
else {
  print "Does not exist\n";
}

Open in new window

0
 
LVL 2

Author Comment

by:rkckjk
ID: 22860761
Doesn't work it returns 0.
0
 
LVL 2

Author Comment

by:rkckjk
ID: 22860780
Doesn't work it comes back with Exists
0
 
LVL 48

Expert Comment

by:Tintin
ID: 22863245
Really?  Can you please show me this behaviour by adding a print before the if test.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

728 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