Halting a program when network unavailable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Halting a program when network unavailable
# 1  
Old 03-02-2009
Halting a program when network unavailable

After installation of FreeBSD there are post installation activities to be executed through a script. Since these activities are dependent upon a network being available, I want the script to detect whether a network connection is present or else halt the script. I currently have this test:
Code:
# ifconfig | grep 192.168.1
inet 192.168.1.14 netmask 0xffffff00 broadcast 192.168.1.255

In other words, the script will check whether the IP address 192.168.1.x can be found. Is there a more robust way of checking whether an internet connection or network connection is available?
# 2  
Old 03-02-2009
By querying only the next hop you just make sure there is a network connection, not a connection to the internet. For instance: if you are connected to your DSL-router, but the router provides no internet connection your test will be positive but your attempt to connect to an internet destination will fail.

The more reliable test will be to either ping the host you are going to connect to (if this fails it will not matter why it fails for your purpose) or ping some well-known host (for instance google.com) instead.

I hope this helps.

bakunin
# 3  
Old 03-02-2009
Thank you for your prompt reply and I will try that.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Crash dump and Panic message : RSCT Dead Man Switch Timeout for HACMP; halting non-responsive node

Dear all i have two aix system -Model : P770 -OS version: AIX 6.1 -patch level : 6100-07-04-1216 -ha version : HACMP v 6.1.0.8 -host : A, B last Wednesday, my B system suddenly went down with crash dump. after 1 minute, A system went down with crash dump. I checked the dump of A-system... (6 Replies)
Discussion started by: tomato00
6 Replies

2. Shell Programming and Scripting

Bc: File is unavailable

Hello, Unix-Forum! Yet another problem: var=1.5 bc $var + 3.2 results in File 1.5 is unavailable So I must be doing something wrong but I don't know what. intelinside (2 Replies)
Discussion started by: intelinside
2 Replies

3. UNIX and Linux Applications

Festival halting

I finally got festival text 2 speech to work. I followed a set of instructions but had to make edits to set it up to work (albeit a few warnings). At the end I tried using quit with double quotes inside parentheses and without but could not stop the program (i.e. comes back with "festival>"). ... (0 Replies)
Discussion started by: slak0
0 Replies

4. UNIX for Advanced & Expert Users

fork: Resource temporarily unavailable , server unexpectedly unavailable network connection

Solaris 10 Server refuse to connect :wall: fork: Resource temporarily unavailable , server unexpectedly unavailable network connection , refuse error, disconnect message, fatal error type2, (protocol error type2) Issue has been resolved after taken few steps :b: First of all need to check... (1 Reply)
Discussion started by: taherahmed
1 Replies

5. BSD

Network unavailable after start up

There is a FreeBSD machine which normally has a network connection, but after a recent start up no longer has such a connection. All other computers on the same router do have an active network. Where do I start looking to troubleshoot this? Thanks in advance (2 Replies)
Discussion started by: figaro
2 Replies

6. Solaris

Unavailable/Slow Network Paths in $PATH

At work, I'm in a Solaris environment working with csh, and $PATH is populated with anywhere between 10 and 20 entries. Last week, every command I issued (even "ls") took several seconds, if not an entire minute, to run. Once I moved "/home/sybase/bin" to the end of $PATH, certain commands... (2 Replies)
Discussion started by: acheong87
2 Replies

7. UNIX for Advanced & Expert Users

Fork:resource unavailable

Hello. I have code which create processes with fork(). I set a limit for processes by typing ulimit -u 20. Then I run my code who should create 100 processes. Unfortunately, I have a mistake there and I forgot to quit all of my forked processes when fork gave me return value -1. So I am trapped in... (5 Replies)
Discussion started by: samos
5 Replies

8. Programming

How to recognize that the server is currently unavailable?

hi all How to recognize that the server is currently unavailable? by programatically.give some example. am using fedora5 AMD cheers (2 Replies)
Discussion started by: munna_dude
2 Replies

9. Solaris

Device PS1 AC UNAVAILABLE

Hi im getting this error on my solaris server. sscprvmds001 picld: Device PS1 AC UNAVAILABLE Does anyone know what this means (1 Reply)
Discussion started by: dennisca
1 Replies

10. Programming

Simple Network Program Difficulties

I'm trying to write 2 programs, client & server, that communicate with integers, however, all resources I have found on the net assume that you want to send and recieve information as a character array. I don't want to send my integers as characters, I want to send them as ints (casting them to... (2 Replies)
Discussion started by: Mistwolf
2 Replies
Login or Register to Ask a Question