LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-11-2013, 06:37 AM   #1
richardmaxxx
LQ Newbie
 
Registered: Dec 2013
Location: London
Distribution: Redhat
Posts: 1

Rep: Reputation: Disabled
wrong returne value


Hi All
when i am using this command in the localhost

[CODE]
Code:
Server_Name:apache:/opt/apache $ ps -ef | grep -i http | grep -i xxxx
root     	       30383     1  0 10:49 ?        	 00:00:00 /opt/apache/xxxx/bin/httpd -f /opt/apache/xxxx/conf/httpd.conf 
User_name   30384 30383  0 10:49 ?        00:00:00 /opt/apache/xxxx/bin/httpd -f /opt/apache/xxxx/conf/httpd.conf 
User_name   30385 30383  0 10:49 ?        00:00:32 /opt/apache/xxxx/bin/httpd -f /opt/apache/xxxx/conf/httpd.conf 
User_name   30386 30383  0 10:49 ?        00:00:33 /opt/apache/xxxx/bin/httpd -f /opt/apache/xxxx/conf/httpd.conf 

Server_Name:apache:/opt/apache $ ps -ef | grep -i http | grep -i xxxx | awk '{print $10}' | grep -v grep | uniq
/opt/apache/xxxx/conf/httpd.conf

when i use the ssh command to run the same command in another server

Code:
Server_Name:apache:/opt/apache $ ssh -q Server_Name " ps -ef | grep -i http | grep -i xxxx | awk '{print $10}' | grep -v grep | uniq "
0
why the difference happen in the result of this 2 command on localhost and using ssh to run the same command on remote server

Last edited by richardmaxxx; 12-11-2013 at 06:41 AM.
 
Old 12-11-2013, 06:52 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
probably ps returns something else, you need to check the output.
You can simplify it by:
ps -ef | awk '/[/]xxxx.*http/{print $10}' | uniq
also uniq can be eliminated (if you wish)
You can also modify your ssh to execute only ps on the remote side:
ssh -q Server_Name "ps -ef" | awk command...
 
1 members found this post helpful.
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrong disk free space (VERY wrong) macrojd Linux - Server 12 05-17-2009 02:14 AM
rsync uses wrong directory, has wrong size but right file count? brianpbarnes Linux - Software 1 02-23-2009 05:48 PM
Fortran - G95 - Wrong Syntax or wrong compiler settings laucian Programming 1 03-21-2008 10:18 AM
What is wrong with reiserfs? wrong free space mesh2005 Linux - General 1 05-03-2007 07:21 AM
my time is wrong and calender is also wrong Paxmaster Linux - General 6 12-16-2004 12:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:29 AM.

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