LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Affirming KPPP/PPPD Connection Success (https://www.linuxquestions.org/questions/slackware-14/affirming-kppp-pppd-connection-success-379079/)

Woodsman 11-01-2005 04:34 PM

Affirming KPPP/PPPD Connection Success
 
I'm writing a bash script to run some additional tasks in addition to actually dialing up and connecting. Before I run those additional tasks, I'm looking for a reliable method to determine that I have successfully connected with my dial-up. If not I want the script to terminate. I use KDE and the KPPP dialer.

Through some testing I noticed I can search for the PID of the PPP daemon. That is one clue that KPPP probably has connected successfuly. After some trial runs this method seems to work. However, I'm thinking that there might be an intermediate stage in the connection process where my script affirms that the PPP daemon PID exists, but the daemon has not yet fully connected. Thus, I'm thinking that extracting the assigned IP address from ifconfig might be a more reliable method of affirming I'm online.

I'm absolutely no grep expert (although learning!). I can perform a simple grep to extract the inet addr: line, but this request returns two lines, one for ppp0 and one for lo. I want to return only the address info from ppp0, and then to parse or extract the actual address. That should affirm I'm fully online.

Perhaps there is a better method, but if not, all help is, as always, appreciated!

uopjohnson 11-01-2005 06:51 PM

Why don't you ping something? If you get a response then you are certainly connected.

Woodsman 11-01-2005 08:49 PM

Quote:

Why don't you ping something? If you get a response then you are certainly connected.
A ping would work, but I need to create some kind of delay loop until the PPP daemon is fully connected. That is, a ping will fail during the intermediate period while pppd is connecting and handshaking. And what if the line is busy? I don't want to ping forever. So looking at the status of ifconfig or the pppd PID seemed more reasonable to me.

Dankles 11-01-2005 08:52 PM

yea, uopjohnson is right, u could include the ping fuction at the beginning of your script, and if it fails, kill the script

uopjohnson 11-03-2005 10:31 AM

OK, well you can definitely use a timeout or something in your script to wait a bit between pings, if you really want to use ifconfig you are going to run across the same problem of constantly checking to see if the interface has connected. The advantage of ping is that you can ping the host that you are trying to connect to thereby verifying not only that your connection is up, but also that you can reach that host. If you are worried about pining this host too much, that should be a problem because you will only reach them once (when the connection is successful)
If you are still looking for an ifconfig solution then please post your ifconfig <interface> in both the connected and unconnected states and we can look at how to tell the difference.

Woodsman 11-03-2005 02:38 PM

Well, after a night's sleep and subsequent reflection, the ping test probably is the best way to go. The goal of these kinds of tests is to verify the complete line from point A to B. Any test in between is subject to failure for various reasons. The ping is a solid way to validate everything is working and online.

With respect to this thread, I have written some scripts that perform several tasks related to dial-up accounts. Such as automatically dialing out with the KPPP dialer, not starting ntpd unless confirming a connection, creating a simple keep-alive routine, etc.

The "problem" of always pinging the same source does bother me. I might add something to the script to rotate through a list of several sites so as not to easily lift eyebrows. I would exclude pinging the ISP because I have noticed that occasionally when the ISP fails I still can ping the ISP but essentially have no access to the remainder of the web. I also only need ping once to confirm the connection (Give me a ping, Vasilly. One ping only, please. :) )

FWIW, eventually I hope to provide a small web site or blog where I'll post the results of these many questions. Thus, many people here will be able to benefit from my seemingly never-ending questions!

uopjohnson 11-03-2005 04:03 PM

It is amazing how often this little penguin leads us down the road of pointless discovery. I can't even count the number of times I have learned three things in order to get one thing to work right and then when I got back to that one thing, found out it was the wrong way to go.
Keep on truckin.


All times are GMT -5. The time now is 02:19 AM.