Results 1 to 2 of 2
I have a exercise. I tried it but it has problems that I can't deal with. Would you please help me? Here is codes Code: #!/bin/bash # network status check ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-22-2011 #1
- Join Date
- Mar 2011
Bash script - sed trouble
Would you please help me?
Here is codes
#!/bin/bash # network status check # parameter 1: ip while [ 1 ]; do if ping -c 10 $1 then echo 'Network ok!' else ifdown eth0 # back up eth1 config cp /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth1.bak # copy eth0 config to eth1 config sed 's/eth0/eth1/' </etc/sysconfig/network-scripts/ifcfg-eth0 >/etc/sysconfig/network-scripts/ifcfg-eth1 ifup eth1 logger -f /var/log/message 'Card eth0 down, switching to eth1' fi sleep 15 done
I see errors when running it but it's success if test with enter commands one by one.
I guess it's due to sed command.
- 03-22-2011 #2