The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-23-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 352
Please help!

Hi All,
I need to run a part of script , until a certain process is running on some other host.

My initial idea was to, do a ssh and check it with ps -ef. Please refer to the command below:


Code:
p=`ssh -q root@hostname ps -ef | grep <process_name> | grep -v grep |wc -l`
If p -gt 1; then
<
Start the code here
>
But since ssh needs a password always, I am using expect script for it.I am not able to figure out, how to pass a parameter value from expect script to shell script.

Please let me know, if anyone knows this, or if anyone has a better way out!

Thanks!
nua7
Reply With Quote
Forum Sponsor
  #2  
Old 07-23-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 1,027
Can you exchange pub keys for passwordless communication?
Reply With Quote
  #3  
Old 07-23-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 352
Well I would love to do that, but that is a security violation here..

Another idea that has come to my mind is create a emty temp file, the other process will create this file and just before it ends, it would delete the file.

I would check for the existence of the file , if the file exists the process is running.

One more idea is to check the pid of the expect script, which is running that application.

Please let me know what you think.

Thanks!
nua7
Reply With Quote
  #4  
Old 07-23-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 1,027
Security violation?
I don't know expect but it has to store the password somewhere too, to make the unattended login. Same as ssh/sftp/scp, which just places it encrypted in the authorized_keys. And it's only the public key so...
Maybe the admin of the other box can give you a limited chroot environment including ps and some more, so you can do your job and he will add your pub key to his authorized_keys.
Reply With Quote
  #5  
Old 07-23-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 352
Thanks zaxxon! I will try to persuade them.
Reply With Quote
  #6  
Old 07-23-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 1,027
Don't forget using a public key that was generated with pressing enter when you were asked for the password/passphrase. Else it will not work and always ask for the PW again.
Reply With Quote
  #7  
Old 07-23-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 352
Sure! I'll keep that in mind.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0