I have the following script code:test.shecho BEGINwhile read CMD <&1; do    [ -z $CMD ] && continue    case $CMD in    start)            echo get_start            ;;    stop)            echo get_stop            ;;    *)            echo get_uknown_command            ;;    esac    echo END;doneWhen I run it with:$./test.sh <input.txtI get my script lockedinput.txtstartstopsthhWhy my script is locked? How I can fix that?BTW: If I enter the data manually then the script will not lock.
Using a file input as stdin for a shell script does not work
linux;shell;input;stdin
Your second line is incorrect, and overly complex anyway. The file descriptors for stdin, stdout, and stderr are 0, 1, and 2, respectively, so to read from stdin you'd want to have while read CMD <&0; do However, since stdin is the default input for read,while read CMD; dois really the simplest way to go. This way, you can manually enter the commands, or use redirection on the command line to read from a file.