Solved

Convert Korn shell echo status to Perl

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

759 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

20 Experts available now in Live!

Get 1:1 Help Now