cancel
Showing results for 
Search instead for 
Did you mean: 

conditional grep thru ftp

Renda Skandier
Frequent Advisor

conditional grep thru ftp

Hi,
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 ]
then
tail afiles
fi

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

Re: conditional grep thru ftp

Shalom,

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.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
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

thanks
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.

Regards!

...JRF...