Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #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

    # network status check
    # parameter 1: ip
    while [ 1 ]; do
            if ping -c 10 $1
                    echo 'Network ok!'
                    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
                    ifup eth1
                    logger -f /var/log/message 'Card eth0 down, switching to eth1'
    sleep 15

    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.

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Seattle, WA, USA
    Homework problems are not allowed as per the forum rules:

    I suggest taking the exact error that you are encountering and try googling for it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts