LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 11-01-2005, 04:34 PM   #1
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,476

Rep: Reputation: 532Reputation: 532Reputation: 532Reputation: 532Reputation: 532Reputation: 532
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!
 
Old 11-01-2005, 06:51 PM   #2
uopjohnson
Member
 
Registered: Jun 2004
Location: San Francisco
Distribution: Slackware, Ubuntu, RHEL, OS X
Posts: 159

Rep: Reputation: 30
Why don't you ping something? If you get a response then you are certainly connected.
 
Old 11-01-2005, 08:49 PM   #3
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,476

Original Poster
Rep: Reputation: 532Reputation: 532Reputation: 532Reputation: 532Reputation: 532Reputation: 532
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.
 
Old 11-01-2005, 08:52 PM   #4
Dankles
Member
 
Registered: May 2004
Location: /dev/null
Distribution: Slackware
Posts: 245

Rep: Reputation: 31
yea, uopjohnson is right, u could include the ping fuction at the beginning of your script, and if it fails, kill the script
 
Old 11-03-2005, 10:31 AM   #5
uopjohnson
Member
 
Registered: Jun 2004
Location: San Francisco
Distribution: Slackware, Ubuntu, RHEL, OS X
Posts: 159

Rep: Reputation: 30
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.
 
Old 11-03-2005, 02:38 PM   #6
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,476

Original Poster
Rep: Reputation: 532Reputation: 532Reputation: 532Reputation: 532Reputation: 532Reputation: 532
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!
 
Old 11-03-2005, 04:03 PM   #7
uopjohnson
Member
 
Registered: Jun 2004
Location: San Francisco
Distribution: Slackware, Ubuntu, RHEL, OS X
Posts: 159

Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kppp is working pppd not xprometeus Linux - Networking 1 11-29-2005 10:34 AM
pppd and kppp, can't connect: stuck with NO CARRIER towsonu2003 Linux - Networking 6 10-13-2005 07:10 PM
kppp/pppd error not letting me log on to Internet nickadeemus2002 Linux - Networking 5 01-28-2005 04:27 PM
KDE 2.2.2 - Kppp / pppd problem i58 Linux - Software 2 11-03-2003 02:37 PM
kppp/pppd kilimanjaro Linux - Networking 11 07-26-2003 01:04 PM


All times are GMT -5. The time now is 08:22 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration