On Tuesday 05 May 2009, george@annamsoft.com wrote:
Can you pl. explain me the below line from your while...do loop.
if ifconfig ppp$iface > /dev/null 2>&1
$iface is 0 or 1 or whatever. ppp$iface is ppp0 or ppp1...
ifconfig ppp0 > /dev/null 2>&1 will try to get the status of interface ppp0. We discard the output of ifconfig since we're not interested in it by sending it to /dev/null.
ifconfig exits with 0 (true) or non-zero (false) depending on whether it could get that status of the specified interface or not. We check the exit value in the if and perform tasks accordingly.
help if man ifconfig man sh (look at the REDIRECTION and Parameter Expansion sections)
Regards,
-- Raju
while : do for iface in 0 1 do if ifconfig ppp$iface > /dev/null 2>&1 then /sbin/route delete default /sbin/route add default dev ppp$iface fi done done