Keywords: Intellon, Atheros, Qualcomm, HomePlug, powerline, communications, INT6000, INT6300, INT6400, AR7400, AR7420

User Interaction
Prev | Chapter 6. Scripting | Next

## User Interaction

Scripts should be designed, whenever possible, to perform correctly without user intervention but there are cases where user intervention is appropriate. The following example illustrates one bash shell method that only requires user input when default values are wrong.

    MAC=00:B0:52:00:BA:BE
    echo -n "MAC Address [${MAC}]: "; read
    if [ ! -z ${REPLY} ]; then
            MAC="${REPLY}"
    fi

First, we define symbol MAC with a default value. The Linux echo utility prints a prompt on the console that includes the symbol value. The trailing newline is suppressed (`-n`) so that text can be typed immediately after the prompt. The echo command is terminated with semicolon (`;`) so that another command can be included on the same line. The shell read statement waits for the user to type something and press the `enter` key. The shell will assign the input to shell variable `REPLY`. The value of `REPLY` is evaluated and used to redefine the symbol only if the input was a non-zero length string.

    MAC Address [00:B0:52:00:BA:BE]:

The user will see something like this. If the value is correct the user can press the `enter` key to generate a zero length string. Otherwise, the user can type the correct value before pressing the `enter` key.

Prev | Up | Next
Reading PHY Rates | Home | Chapter 7. Support Function Reference