>From within the script "echo $$" will give you the PID of the current process.
If you are executing another script in the background from within a script or
on the command line, after executing, typing "echo $!" will return the PID of
that process, This is of course assuming your using Korn, Bourne, or Bash
shells.

In a message dated 06/26/1998 3:58:59 PM Central Daylight Time,
[EMAIL PROTECTED] writes:

<< Hi,
 
 I am trying to obtain the 'pid' of a script for when I do logging and
 back tracking. The script is initiated from a shell command within the
 ppp option files.  It happens like this:
 
 A caller calls in and connects using ppp.  An ppp option file for that
 serial port (ie options.ttyC6) includes the 'welcome' option.  The ppp
 'welcome' option initiates a shell that takes a commandline for an
 argument.  In this case the 'welcome /etc/sysconfig/network-scripts/isp
 start ttyC6 &'.
 
 The isp script checks for and monitors the main connection to the
 internet,  and logs to the syslogd. When the dialin user hangs up, pppd
 will also kill the script.  
 
 For logging and accounting purposes I need to track the connection and
 up time of the connection. I will have to do this through pids.  The
 problem is I cannot seemed to collect the correct pid. Every dialin
 connection has an instance of the script, so sometimes i have 6 to 10 of
 them all monitoring it own dialin port and insuring it has Internet
 continuity. The only difference between each instance is the ttyCx
 commandline option. The 'pidof' function keeps returning the pidof the
 first instance.  When I do ps faux I see the pid in the logfile is not
 the correct pid. In the script I do the following:
 
 #!/bin/sh
 #
 # isp          This shell script takes care of starting and stopping
 #              Main Internet Connection
 #
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 ISPSH="sh $0 $1 $2"
 PID=`pidof -s $ISPSH`
     ^--(back tic)---------^ My email client changed this to '
 INFOENTRY="-p local0.info -t isp.sh[$PID]"
 
 --<snip>--
 
 [ -f $SCRIPT_HOME/isp ] || exit 0
 case "$1" in
   start)
     logger $INFOENTRY "Looking for ISP Connection for $2"
 
 --<snip to EOF>--
 
 What kind of input can you give me on this?  Hopfully a solution.
 
 thanks in advance
 --
 robert
 
 
 -- 
   PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
 http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
          To unsubscribe: mail [EMAIL PROTECTED] with 
                        "unsubscribe" as the Subject.
 
  >>


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

  • pidof Robert W. Canary
    • HoffmansJG

Reply via email to