Ssh and pgrep not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ssh and pgrep not working
# 1  
Old 10-29-2013
Ssh and pgrep not working

I have setup SSH keys . Trying to grep to get PID of remote jvm's .

this is what am doing
Code:
ssh -q testuser1@myhost.com 'PID1=pgrep -fl testapp1|awk "{print $1}";PID2=pgrep -fl testapp2|awk "{print $1}" '
echo $PID1, $PID2

it throws error"sh: -fl: command not found"

---------- Post updated at 07:36 PM ---------- Previous update was at 07:12 PM ----------

please ignore my question , I was able to figure out

Last edited by Franklin52; 10-30-2013 at 04:44 AM.. Reason: Please use code tags
# 2  
Old 10-30-2013
Code:
cat remotescript
#!/bin/sh
PID1=`pgrep -fl testapp1 | awk '{print $1}'`
PID2=`pgrep -fl testapp2 | awk '{print $1}'`
echo $PID1,$PID2

Code:
ssh -q testuser1@myhost.com /bin/sh < remotescript

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Echo/kill pgrep

Hi folks. I'm wondering why the following doesn't work and hoe to fix it... I can: # pgrep foo 1234 I can: # echo | pgrep foo 1234 But I can't # kill | pgrep foo kill: usage: blah blah So why does echo pipe correctly but kill doesn't? (9 Replies)
Discussion started by: MuntyScrunt
9 Replies

2. Shell Programming and Scripting

Pgrep not showing desired output

I am searching for a process that should be up and running. Im using the following command ps -ef | grep elasticsearch to get elastic+ 1673 1 0 Jan29 ? 05:08:56 /bin/java -Xms4g -Xmx4g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC... (1 Reply)
Discussion started by: Junaid Subhani
1 Replies

3. Shell Programming and Scripting

Pgrep for processes which are not associated with a terminal in Ubuntu

I would like to find all of the PIDs of processes which are not associated with a terminal and started by CRON. When I do the ps aux | less command, I see in the TTY field a lot of processes with ? character I would like to get those processes ID, is there a way to do that with pgrep? ... (1 Reply)
Discussion started by: ASF Studio
1 Replies

4. Red Hat

SSH not working

Hi, I have a server running RHEL 6.0. While logging in through root ,I can login.But if I try to login through "integ" user,I am unable to login. /var/log/secure messages::: May 20 15:25:23 punsyncserv su: pam_unix(su-l:session): session opened for user integ by root(uid=0) May 20 15:29:44... (4 Replies)
Discussion started by: nowornever
4 Replies

5. UNIX for Dummies Questions & Answers

SSH tunnel working for ssh but not for sshfs

I'm trying to setup a link between my home pc (work-machine) and a server at work (tar-machine) that is behind a gateway (hop-machine) and not directly accessible. my actions: work-machine$ ssh -L 1234:tar-machine:22 hop-machine work-machine$ ssh -p 1234 user@127.0.0.1 - shh access on... (1 Reply)
Discussion started by: Vathau
1 Replies

6. Solaris

SSH: internal working but external not working

Hi, This is a strange issue: We have an sftp server. Users can ssh to it from internal LAN without any issue, but they can not ssh to it externally via firewall. Here is what I got: OS is Solaris 9. No hosts.allow and hosts.deny files. Please help. Thank you in advance! (7 Replies)
Discussion started by: aixlover
7 Replies

7. HP-UX

ssh to server is not working

When we ssh -i private key user@ip we get the password prompt. The sending servers public key is in the receiving server. We have blown away the known_hosts file on the sending server and restarted the ssh connection. We don't know what else to do. Any other suggestions? (15 Replies)
Discussion started by: jastanle84
15 Replies

8. UNIX for Dummies Questions & Answers

PGREP Arguments

I'm trying to figure out how to use pgrep to pull the arguments of a process. Given: root 308 1 0 00:00 ? 00:00:00 /bin/sh /some/random/path/somescript.sh -flag /another/path/blahI can get the pid (308) using this command: pgrep shHowever, what if I wanted to pull by "somescript.sh"... (4 Replies)
Discussion started by: mrwatkin
4 Replies

9. AIX

ssh is not working !

Guy's I have AIX 6.1 SSH in it is not working but is up and Active ..... server1/etc>lssrc -s sshd Subsystem Group PID Status sshd ssh 450686 active from my PC can I login by SSH but SSH from Server1 to Server2 is not accepting it's giving me this message server1/etc>ssh sever2... (4 Replies)
Discussion started by: ITHelper
4 Replies

10. Programming

pgrep returns 256

Hi Everyone, I have a strange behaviour In my c program i use this line: int retval = system("pgrep encoder"); while i expect retval to contain 0,1,2,3 i get 256. did i do something wrong? thanks, Alex (2 Replies)
Discussion started by: alex889
2 Replies
Login or Register to Ask a Question