SlackwareThis Forum is for the discussion of Slackware Linux.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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!
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.
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.
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!
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.