Showing results for 
Search instead for 
Did you mean: 

conditional grep thru ftp

Renda Skandier
Frequent Advisor

conditional grep thru ftp

I'm trying to grep for a process & if it exists, tail a file. This needs to be done thru a ftp script

Checks for the process
sndline "ps -eaf | grep process | grep -v grep"
receive ">"

I know if I was in a script, I could
ps -eaf | grep process | grep -v grep
if [ $? -eq 0 ]
tail afiles

How do I put the 2 together?
Steven E. Protter
Exalted Contributor

Re: conditional grep thru ftp


grep command is not available in an ftp session.

You must use grep to create a file and then a second process to ftp it where you want it to go.

You can in your second loop integrate an ftp scrip loop.

Steven E Protter
Owner of ISN Corporation
Renda Skandier
Frequent Advisor

Re: conditional grep thru ftp

ftp is the wrong term :(
I'm actually using a tcp connection to various addresses and check for a hung process

sndline "ps -eaf | grep process| grep -v grep"
receive ">"

works and displays to my screen. If the process exists, I'd like to tail a file

James R. Ferguson
Acclaimed Contributor

Re: conditional grep thru ftp

Hi :

I suppose you could get there from here in a round-about fashion.

You could execute an FTP script and within the FTP session do:

!ps -ef ...

You would want to collect the FTP session in a file that you can parse. Use the '-v' option to FTP and redirect like:

ftp -in -v >> /var/tmp/ftp.$$ 2>&1

Once you have run the *first* ftp, examine the log you created and based on its contents execute a second FTP to do whatever you want.