Grep the exact process in perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep the exact process in perl script
# 1  
Old 12-16-2014
Grep the exact process in perl script

I am working on one script where I need to grep the exact process in perl script.

for e.g. when I run simple grep command on the linux machine it gives me two process mGateway_mvc_q01 and mGateway_mvc_q01_v7 which is not the correct result.I tried to use ( ps -eAf | grep ^mGateway_mvc_q01$) but that is not working..I want only mGateway_mvc_q01 process.Can someone help me how could I achieve this through perl script.I don't want to use any other new file to store the value..

Quote:
ps -eAf | grep mGateway_mvc_q01(don't want below output in perl)

websrvr 22568 1 0 08:12 ? 00:00:00 /bin/sh /opt/JBoss/jboss-7.1.1.Final/bin/standalone.sh -Djboss.server.name=mGateway_mvc_q01_v7 -Djboss.server.base.dir=/opt/JBoss/jboss-7.1.1.Final/server/mGateway_mvc_q01_v7 -b=10.180.4.210

websrvr 26125 1 0 12:10 ? 00:00:00 /bin/sh /opt/JBoss/jboss-6.1.0.Final/bin/run.sh -c mGateway_mvc_q01 -b 10.180.4.207


ps -eAf | grep mGateway_mvc_q01(want below output in perl)

websrvr 26125 1 0 12:10 ? 00:00:00 /bin/sh /opt/JBoss/jboss-6.1.0.Final/bin/run.sh -c mGateway_mvc_q01 -b 10.180.4.207
# 2  
Old 12-16-2014
Code:
.... | grep ' mGateway_mvc_q01 '

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find the exact process using ps aux command?

Please do not post a technical question in the @How to contact....' forum. I have moved this for you. Hello Everyone, Please help me on this, Requirement here is to check whether the process is running using the process id. For the below scenario, I m trying to grep 1750 process id to... (3 Replies)
Discussion started by: Hari A
3 Replies

2. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies

3. Shell Programming and Scripting

Grep for process in a ksh script

Hi I'm trying to catch a particular process (XYZ) running using a ksh script. Like So.. VarPS=`ps -ef |grep XYZ |grep -v grep` However this seems to find the process of the script itself - not the process 'XYZ' Asked in Error - I found my own typo... thanks anyway Skrynesaver (1 Reply)
Discussion started by: Mudshark
1 Replies

4. UNIX for Dummies Questions & Answers

Grep exact value

Hello All, I have a file all_info.txt Date Owner Filename 03/25/2014 mycomp\royale myfile_ goodfile_sec_20140324_c.zip 03/25/2014 mycomp\royale myfile_goodfile_sec_20140324_c.cpt 03/25/2014 mycomp\royale1 ... (9 Replies)
Discussion started by: kumar30213
9 Replies

5. Shell Programming and Scripting

QUESTION1: grep only exact string. QUESTION2: find and replace only exact value with sed

QUESTION1: How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1 CAR2_KEY0 CAR2_KEY1 CAR1_KEY10 CURRENT COMMAND LINE: WHERE VARIABLE CAR_NUMBER=1 AND KEY_NUMBER=1 grep... (1 Reply)
Discussion started by: thibodc
1 Replies

6. UNIX for Dummies Questions & Answers

grep exact

FILE: #test file# server1 10.1.1.1 server2 10.1.1.2 server2-prv 10.1.1.3 grep -w "server2" {filename} Returns: server2 10.1.1.2 server2-prv 10.1.1.3 How would you just get it to return just the exact match line?: server2 10.1.1.2 Thanks! (4 Replies)
Discussion started by: trimike
4 Replies

7. Shell Programming and Scripting

How to grep the exact name?

I'm attempting to perform an exact match on an input data column with another input file but cannot figure out how to code the "grep" statement to handle 2 specific scenarios. I’m capturing the first column of data from $ifile2 into variable $rule and using it to perform a “grep” on $ifile3 to... (4 Replies)
Discussion started by: ltf1833
4 Replies

8. UNIX for Dummies Questions & Answers

Filtering exact process name from ps

Hi Gurus, I have two processes running on a Unix box, named say, PRCS1 and PRCS1X. I want to check whether process PRCS1 is running or not, and depending on that I have to make further decisions while writing a shell script. I am using: ps -eaf|grep PRCS1|grep -v grep But the... (2 Replies)
Discussion started by: sagarparadkar
2 Replies

9. Shell Programming and Scripting

How to grep the exact name?

Hi All Here is one o/p from a program I have ... Can someone tell me the way so that I get only the output by the user "li" not the other users which have "li" in the name. Surely I dont like the idea Thanks a lot to all in advance C Saha (3 Replies)
Discussion started by: csaha
3 Replies

10. Shell Programming and Scripting

Perl: Run perl script in the current process

I have a question regarding running perl in the current process. I shall demonstrate with an example. Look at this. sh-2.05b$ pwd /tmp sh-2.05b$ cat test.sh #! /bin/sh cd /etc sh-2.05b$ ./test.sh sh-2.05b$ pwd /tmp sh-2.05b$ . ./test.sh sh-2.05b$ pwd /etc sh-2.05b$ So... (10 Replies)
Discussion started by: vino
10 Replies
Login or Register to Ask a Question