?
Solved

Convert Korn shell echo status to Perl

Posted on 2008-11-02
5
Medium Priority
?
455 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:Richard Kreidl
[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 2000 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:Richard Kreidl
ID: 22860761
Doesn't work it returns 0.
0
 
LVL 2

Author Comment

by:Richard Kreidl
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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
Suggested Courses

777 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