Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-18-2008, 01:26 PM   #1
LQ Newbie
Registered: Mar 2008
Posts: 5

Rep: Reputation: 0
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.

AMQ8408: Display Queue Manager details.
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.

Thanks for helping me!
Old 03-18-2008, 03:50 PM   #2
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35

How is the print command causing a shell script to run? I'm a little rusty with Perl.
Old 03-18-2008, 05:28 PM   #3
Registered: Mar 2008
Posts: 101

Rep: Reputation: 15
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

Last edited by prad77; 04-17-2008 at 04:12 AM.
Old 03-18-2008, 07:28 PM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
You could change this
print `$temp | egrep "QMGR|SCH"`;
`echo $temp | egrep "QMGR|SCH"`;
if I follow you correctly.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Analyzing /usr/bin/lsattr `echo $PATH | tr ':' ' '` | grep i-- Redshift Linux - Security 2 03-27-2007 09:54 PM
ls | echo, I got blank, why can't echo take the 2nd seat in a pipeline? elinuxqs Linux - Newbie 6 11-24-2006 09:25 AM
BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then" eur0dad Programming 9 07-27-2006 03:14 PM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 03:59 PM
expect scripting syntax problems...(catch, echo,....) wedgeworth Linux - Software 2 10-02-2003 10:24 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:12 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration