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 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 1
Bash script - sed trouble
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 # 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
Homework problems are not allowed as per the forum rules:
http://www.linuxforums.org/forum/lin...ums-rules.html
I suggest taking the exact error that you are encountering and try googling for it.



