On Thursday 04 November 2004 08:42, faisal gillani wrote:
> Hello there ...
>
> well i want to make a simple/wieard shell script :)
> which checks somehow
> connection with the internet & rename some file files
> if it finds
> connectivity with the internet , & do nothing of it
> dont find connectivity
> with the internet ...is it possible with simple shell
> script ? or do i have
> to learn some scripting language for that ?
> CAN U HELP !!! :)

Try something like this :
---- cut here -----
#!/bin/sh

connection=0
ping -c 5 -t 6 some.host.on.the.internet && connection=1

if [ "${connection}" = "1" ]; then
        # This will be executed if we can ping the host
        echo "We have internet. :)"
else
        # This will be executed if we can't ping the host (no connection)
        echo "Oh no!! Someone please help me."
        echo "We're not connected!!"
fi
---- end of script ---

The "ping" command tries to ping some host on the internet 5 times and waits 
for a maximum of 6 seconds for a reply. If ping gets a reply, the variable 
"connection" will be set to 1.
The "if" statement checks the "connection" variable and executes whatever you 
want to do then.

grtz,
Daan

_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to