Problems with grep when used with echo
I am trying to run the below lines from within a perl script:
my $temp=`echo "DISPLAY QMGR DEADQ SCMDSERV SCHINIT" | runmqsc`; print `$temp | egrep "QMGR|SCH"`; But, I get an error saying: sh: syntax error at line 1: `5724-H72' unexpected The output when we run the above command from ksh will be: bash-2.03$ echo "DISPLAY QMGR DEADQ SCMDSERV SCHINIT" | runmqsc 5724-H72 (C) Copyright IBM Corp. 1994, 2005. ALL RIGHTS RESERVED. Starting MQSC for queue manager NIMESU02. 1 : DISPLAY QMGR DEADQ SCMDSERV SCHINIT AMQ8408: Display Queue Manager details. QMNAME(NIMESU02) DEADQ(DEAD.LETTER.QUEUE) SCHINIT(QMGR) SCMDSERV(MANUAL) One MQSC command read. No commands have a syntax error. All valid MQSC commands were processed. Thanks for helping me! |
confusion
How is the print command causing a shell script to run? I'm a little rusty with Perl.
|
You have to shuffle up between single, double and back quotes. I am not sure which set goes with shell scripting and which ones with perl. But it will go well handy with proper set of quotes.
Fedora Development |
You could change this
print `$temp | egrep "QMGR|SCH"`; to `echo $temp | egrep "QMGR|SCH"`; if I follow you correctly. |
All times are GMT -5. The time now is 03:05 AM. |