network script syntax problem
Ari Moisio
arimo at iki.fi
Fri Nov 6 12:59:51 UTC 2015
Hi
The $(...) does not capture stderr output.
Could you use ping exit code directly; it will fail in it got no
repllies.
--
mr. M01510 & guide Loadstone-GPS
Lat: 62.38718, lon: 25.64672
hkp://wwwkeys.pgp.net B784D020
0C1F 6A76 DC9D DD58 3383 8B5D 0E76 9600 B784 D02
Jude DaShiell kirjoitti
> Subject: network script syntax problem
> Date: Fri, 6 Nov 2015 07:08:46 -0500 (EST)
> From: Jude DaShiell <jdashiel at panix.com>
> To: blinux-list at redhat.com
>
> #!/usr/bin/env bash
> # file: $0 - script to find useable connection on hughsnet.
> let CONNECT=0
> while [ $CONNECT -lt 1 ]; do
> sudo -H dhcpcd -k 2>&1 >/dev/null
> sudo -H dhcpcd
> ST=$( ping -c 5 8.8.8.8|tail -2 )
> if [ $ST !='connect: Network is unreachable' ]; then
> CONNECT=CONNECT+1
> fi
> done
>
> The ST variable doesn't capture the search string the if statement is needing
> to find. Putting parentheses around a command appears only to capture output
> of a command and send it to stdout or stderr. In case of bad network
> connections this script first kills dhcp then reconnects. If successful it
> need only happen once.
>
> --
>
> _______________________________________________
> Blinux-list mailing list
> Blinux-list at redhat.com
> https://www.redhat.com/mailman/listinfo/blinux-list
>
More information about the Blinux-list
mailing list