Results 1 to 10 of 10
Hi,
I'm trying to write a boot-up script that will perform functions that require network connectivity, but it always is executed before I have connection. Is there any way that ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-14-2011 #1Just Joined!
- Join Date
- Jun 2011
- Posts
- 9
Verify network connection via non-interactive command line
Hi,
I'm trying to write a boot-up script that will perform functions that require network connectivity, but it always is executed before I have connection. Is there any way that I can use a command line utility to check for network connection and only continue the script once I have it? I thought about pinging, but this script will go on computers in various places, and I can't trust that all routers will necessarily respond to ping.
- 07-15-2011 #2
How about just having the sysadmin place the script start after the interface startup?
- 07-15-2011 #3Just Joined!
- Join Date
- Jun 2011
- Posts
- 9
Problem is that it needs root permissions, and login scripts can't execute with root permissions.
One thing I found that sort of works as a workaround is:
ping -c 1 www dot usa dot gov
and then check the exit status (this assumes, of course, that wwwusagov is a fairly static domain that isn't going away any time soon). I'd like to have a less hack-y way of doing it though.
(btw, dot in urls is because this forum won't let me post URLs)
- 07-18-2011 #4
If the script is run during normal bootup it is executed as root.
- 07-18-2011 #5Just Joined!
- Join Date
- Jun 2011
- Posts
- 9
- 07-18-2011 #6
See what I posted in my first post this will start your script after the interface is started.
- 07-18-2011 #7Just Joined!
- Join Date
- Jun 2011
- Posts
- 9
Yes, but I'm not sure that interface startup necessarily guarantees internet connectivity. It's a good bet, but it's not an assurance.
- 07-18-2011 #8Just Joined!
- Join Date
- Jun 2011
- Posts
- 9
Not to say I don't like the idea, though; it's a clever idea.
- 07-20-2011 #9
Then write your program to check for internet connection and if there is none then abort. Pinging the GW should be enough for network connectivity.
- 07-20-2011 #10Just Joined!
- Join Date
- Jun 2011
- Posts
- 9
What I wanted to do was have it loop for a minute or so and then quit. Embarrassingly, I couldn't figure out how to get the math working for that (also, I don't know what kind of shell is run at bootup). Literally, though, I couldn't get a simple subtraction and comparison to work. It's very embarrassing.


Reply With Quote

