LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-18-2008, 12:26 PM   #1
pavan_pnv
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.


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!
 
Old 03-18-2008, 02:50 PM   #2
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
confusion

How is the print command causing a shell script to run? I'm a little rusty with Perl.
 
Old 03-18-2008, 04:28 PM   #3
prad77
Member
 
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 03:12 AM.
 
Old 03-18-2008, 06:28 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

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


Reply



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 08: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 08:25 AM
BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then" eur0dad Programming 9 07-27-2006 02:14 PM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 02:59 PM
expect scripting syntax problems...(catch, echo,....) wedgeworth Linux - Software 2 10-02-2003 09:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:02 PM.

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