Hi,
I've a C Shell script inside which I do a ftp to a site. Is there any way of taking the PID of that ftp process alone 'coz when I tried to take the PID, I could just get the PID of this script alone. I used $$ to take the PID. Thanks in advance.
hi ecasdella, ur example script works fine when run.. but it is a K-Shell.. i've to use C-Shell.. i think thats why that '!ps' is not working in c-shell... is it the reason..can u pls help me get out of this problem...
ok, to do this you can put this code in a separate script, so that whenever you need to execute it from your c-shell just add this line in your csh script:
ksh ftp_script.ksh
and if you need to pass user and password to the script, do it as common script args like:
ksh ftp_script.ksh $user $pass $host
so in the ksh script you must set them as:
USER=$1
PASS=$2
HOST=$3
once this script finish its execution the c-shell script will keep parsing its own lines.
that's why G-ds created interpreter directives - being on the first line of the "interprative" script - it 'directs' the calling process to use a given/specified interpreter [shell, perl, ruby etc] for the rest for the context of the file.
In your example you should have the following on the FIRST line of your script:
#!/bin/ksh vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
I just don't get it, I execute this script in my machine on a Solaris 7 with csh and it works perfectly, try to isolate this code into a separate script and tell me step by step what you are doing. EDC
--------------------------------------
This is Unix-Land. In quiet nights, you can hear the Windows machines
reboot.
hi ecasadella, below is the script which i'm trying to do.. this script runs every 15 minutes and ftp's to a site to get files... sometimes the ftp session hangs up.. so before invoking this script next time i've to chek whether the previous ftp is still running or not.. if running i've to kill that ftp and start a new one... thanks for your help all the way from y'day...
#!/bin/csh
if ( -f ./myftppid ) then
set oldpid = `cat ./myftppid`
ps -p $oldpid | egrep "ftp" ; set stat = $status
echo $oldpid
while ( $stat == 0 )
# Last invocation of the script still running....
@ x ++
if ( $x == 10 ) then
# tried 10 times to kill it and it wouldn't die
echo "Couldn't kill old process"
echo " "
exit 5
endif
echo "Old FTP still running "
kill -9 $oldpid
sleep 1
ps -p $oldpid | egrep "ftp" ; set stat = $status
end
endif
# put the PID in a file so we can check it next time we start
#echo $$ >! ./myftppid
echo !ps | egrep "ftp" | awk '{print $1}' > ./myftppid
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.