Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP 9000 Networking: Installing and Administering PPP > Chapter 4 Common pppd Options

The exec Option

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

The exec option invokes a command or shell script when a link is brought up or taken down. Exec can be used on the link's calling or answering end and the command or shell script is executed immediately when the link changes state.

The first argument of the command or shell script invoked by exec is either "up" or "down." The second argument is the peer's IP address. Exec's third and subsequent arguments are those with which pppd was invoked.

NOTE: Note: pppd runs suid root and anything specified in the Exec script is run as root. This can be a risk if mismanaged. Take appropriate security precautions with the exec script so it cannot be modified by non-root users.

Parent Environment and Session Variables

The entire parent environment is exported to exec scripts (the environment when pppd was invoked.) You should attempt to make the environment as small as possible because the environment will take up space for each pppd that is running. The exec script may also include variables that describe the current session. These variables include:

VariableDescription
PPPHOMEAs you would expect, but always set.
PPP_COMMANDLINE

All arguments from the original command line.

PPP_LOCALADDRLocal address of link while up (negotiated).
PPP_REMOTEADDRRemote address while up.
PPP_NETMASKNetmask while up.
PPP_ORIG_LOCALADDROriginal local address (from command line).
PPP_ORIG_REMOTEADDROriginal remote address.
PPP_ORIG_NETMASKOriginal netmask.

PPP_INTERFACE

Name of PPP interface (DUX).

PPP_DEVICE

Name of device being used for serial stream.

PPP_LOGFILE

Self-explanatory.
PPP_ACCTFILESelf-explanatory.
PPP_AUTHNAME

Peer name if CHAP/PAP is used, else "name" parameter from command line, if given. Else user name of user that started pppd.

PPP_PID

pppd user process PID.

PPP_SHUTDOWNShutdown reason if link is going down and a shutdown reason is available, else non-existent.

Example

This example uses a Login shell script to invoke an executable shell script called $PPPHOME/Exec. $PPPHOME/Exec causes sendmail to run its queue whenever a remote system establishes a connection, possibly triggering a delivery to the remote system.

Login Shell Script

#!/bin/sh
PATH=/usr/bin:/usr/etc:/etc:/bin
PPPHOME=/etc/ppp
export PPPHOME PATH

mesg n
stty -tostop
exec pppd 'hostname': idle 130 exec $PPPHOME/Exec

Executable Shell Script:

#!/bin/sh
case "$1" in
up) echo link is up at 'date' > /dev/console ;
/usr/lib/sendmail -q < /dev/null ;;
down) echo link is down at 'date' > /dev/console ;;
esac
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997 Hewlett-Packard Development Company, L.P.