script works but wont execute when called by pppd
am 26.07.2005 22:18:13 von golfbufI'm running slackware-10.1.
I'm trying to get my modem connection speed to popup on my desktop.
I'm using pppsetup for my connection.
I added REPORT CONNECT to the beginning of /etc/ppp/pppscript. This
makes chat report the connection speed.
I revised the chat lines in /usr/sbin/ppp-go to divert the reported
connection to /var/log/ppp-errors (by adding -r /var/log/ppp-errors).
Now, when I connect I get a connection listing added to the
/var/log/ppp-errors file, like this:
root :/var/log# cat ppp-errors
Opening "/var/log/ppp-errors"...
chat: Jul 24 14:01:48 CONNECT 48000
Closing "/var/log/ppp-errors".
Opening "/var/log/ppp-errors"...
chat: Jul 24 14:13:56 CONNECT 49333
Closing "/var/log/ppp-errors".
I can get a popup on my user's X by the following kdialog:
root :/etc/ppp# export XAUTHORITY=/home/golfbuf/.Xauthority ;
/opt/kde/bin/kdialog --display :0 --msgbox "`/usr/bin/tail -n3
/var/log/ppp-errors | /usr/bin/grep CON | /usr/bin/cut -c 7-`"
>/dev/null 2>&1 &
[3] 3200
So, I added this to the end of /etc/ppp/ip-up, as follows:
root :~# cat /etc/ppp/ip-up
#!/bin/sh
#
# This file /etc/ppp/ip-up is run by pppd when there's a
# successful ppp connection.
#
# Put any commands you want run after a successful connection
# in this file.
#
# Any commands you want printed to the screen should be directed
# to: >/dev/tty0
#
# Other commands should not be directed to: >/dev/tty0
#
# The companion file is /etc/ppp/ip-down, it's run when the PPP
# connection ends.
#
# This file is created when you run pppsetup: Sun Jul 24 13:39:57 EDT
2005
#
# The environment is cleared before executing this script
# so the path must be reset.
#
PATH=/usr/bin:/usr/sbin:/usr/local/bin:/sbin:/bin
export PATH
# This will print to the screen the local & remote IP address when you
# make a successful ppp connection. $4 = Local IP $5 = Remote IP
#
# The CARRIER speed at which you connected will be reported, if it's in
# the /var/log/messages file. You also need the programs "tail" "cut"
# "tr" "grep" and "syslogd" running for this to work.
# You may have to add S95=46 to your modem init string
# to get your modem to report the DCE = CARRIER speed.
# Example: AT&FS95=46
if [ -s /var/log/messages ] && ( ps xc 2>/dev/null | grep -q syslogd
2>/dev/null ); then
S=`tail -n 30 /var/log/messages 2>/dev/null | grep "CARRIER[^)]"
2>/dev/null | tr -d "^M" 2>/dev/null | cut -d: -f4 2>/dev/null`
echo -n "$S" >/dev/tty0
echo " Local: $4 -> Remote: $5 $1" >/dev/tty0
else
echo " Local: $4 -> Remote: $5 $1" >/dev/tty0
fi
# If you want to ping the other end to keep the connection open.
# The output from ping will goto >/dev/null, you won't see it.
# Ping -i 60 = send ping every 60 seconds to remote = $5.
#(ping -i 60 $5 &) >/dev/null 2>&1
# If you want sendmail to send any mail in /var/spool/mqueue when
# you connect, remove the # below.
#sendmail -q
# If you want fetchmail to get your mail when you connect and check
# every 300 seconds = 5 minutes for mail, remove the # below.
#fetchmail -d 300
export XAUTHORITY=/home/paul/.Xauthority;/opt/kde/bin/kdialog --display
:0 --msgbox "`/usr/bin/tail -n3 /var/log/ppp-errors | /usr/bin/grep CON
| /usr/bin/cut -c 7-`" >/dev/null 2>&1 &
root :~# cat /etc/ppp/ip-up
#!/bin/sh
#
# This file /etc/ppp/ip-up is run by pppd when there's a
# successful ppp connection.
#
# Put any commands you want run after a successful connection
# in this file.
#
# Any commands you want printed to the screen should be directed
# to: >/dev/tty0
#
# Other commands should not be directed to: >/dev/tty0
#
# The companion file is /etc/ppp/ip-down, it's run when the PPP
# connection ends.
#
# This file is created when you run pppsetup: Sun Jul 24 13:39:57 EDT
2005
#
# The environment is cleared before executing this script
# so the path must be reset.
#
PATH=/usr/bin:/usr/sbin:/usr/local/bin:/sbin:/bin
export PATH
# This will print to the screen the local & remote IP address when you
# make a successful ppp connection. $4 = Local IP $5 = Remote IP
#
# The CARRIER speed at which you connected will be reported, if it's in
# the /var/log/messages file. You also need the programs "tail" "cut"
# "tr" "grep" and "syslogd" running for this to work.
# You may have to add S95=46 to your modem init string
# to get your modem to report the DCE = CARRIER speed.
# Example: AT&FS95=46
if [ -s /var/log/messages ] && ( ps xc 2>/dev/null | grep -q syslogd
2>/dev/null ); then
S=`tail -n 30 /var/log/messages 2>/dev/null | grep "CARRIER[^)]"
2>/dev/null | tr -d "^M" 2>/dev/null | cut -d: -f4 2>/dev/null`
echo -n "$S" >/dev/tty0
echo " Local: $4 -> Remote: $5 $1" >/dev/tty0
else
echo " Local: $4 -> Remote: $5 $1" >/dev/tty0
fi
# If you want to ping the other end to keep the connection open.
# The output from ping will goto >/dev/null, you won't see it.
# Ping -i 60 = send ping every 60 seconds to remote = $5.
#(ping -i 60 $5 &) >/dev/null 2>&1
# If you want sendmail to send any mail in /var/spool/mqueue when
# you connect, remove the # below.
#sendmail -q
# If you want fetchmail to get your mail when you connect and check
# every 300 seconds = 5 minutes for mail, remove the # below.
#fetchmail -d 300
export XAUTHORITY=/home/paul/.Xauthority;/opt/kde/bin/kdialog --display
:0 --msgbox "`/usr/bin/tail -n3 /var/log/ppp-errors | /usr/bin/grep CON
| /usr/bin/cut -c 7-`" >/dev/null 2>&1 &
# End...
However, now when I connect, it fails to create the popup.
I can 'root :~#/etc/ppp/ip-up' and the popup appears, so the script
works. But, it seems like it doesn't work when called by chat. I'm
suspecting it's some sort of permission or path problem, but can't
figure it out.
root :~# ls -la /etc/ppp/ip-up
-rwxr-xr-x 1 root root 2132 2005-07-24 14:31 /etc/ppp/ip-up*
Anyone have an idea?
TIA