Solved

Convert Korn shell echo status to Perl

Posted on 2008-11-02
5
436 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Syslog text file into database or into .CSV 19 110
sort hash by values desc 2 186
perl to display a matrix report for 3-dimenional array 3 64
Writing a parser for java language 4 71
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

867 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

17 Experts available now in Live!

Get 1:1 Help Now