Re: custom shell script .. OT maybe .
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]
Re: custom shell script .. OT maybe .
On 2004-11-04 09:26, Daan Vreeken [PA4DAN] [EMAIL PROTECTED] wrote: 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 Ping may be a bit unreliable at times. If you know the interface name you can probably get away by using ifconfig to short-cut through the checks. flags=$(ifconfig sis0 | grep '^sis0:' | \ sed -e 's/.*//' -e 's/.*//' ) case $flags in *UP*) # interface is up, keep going ;; *) echo sis0 interface is down. exit 1 ;; esac Replace sis0 with tun0 and you have something that works just fine for dialup PPP connections ;-) Just my USD $0.02. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: custom shell script .. OT maybe .
Nothing much for OP... in message [EMAIL PROTECTED], wrote Giorgos Keramidas thusly... On 2004-11-04 09:26, Daan Vreeken [PA4DAN] [EMAIL PROTECTED] wrote: On Thursday 04 November 2004 08:42, faisal gillani wrote: 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 ? In the long range, learning will be better. #!/bin/sh connection=0 ping -c 5 -t 6 some.host.on.the.internet connection=1 Ping may be a bit unreliable at times. If you know the interface name you can probably get away by using ifconfig to short-cut through the checks. Problem w/ not actually testing a connection is that there may be an address assigned to the interface (and it would be up) but lacking a meaningful connection, say, courtesy of firewall/dhcp running order/configuration. Well that was my problem w/ ipf dhcp involving a NIC anyway. - Parv -- ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
custom shell script .. OT maybe .
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 !!! :) Thanks take care = *º¤., ¸¸,.¤º*¨¨¨*¤ Allah-hu-Akber*º¤., ¸¸,.¤º*¨¨*¤ __ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]