I was trying to run a shell script and run it through Cygwin terminal in XP environment.
The script I have written is as follows -

read -p "Enter Your name - " fname
if test "$fname" == "abcd"
            echo "Thank you abcd"

When I am trying to run it, after taking the input it gives an error -
': not a valid identifier: read: `fname
Though the commands are working fine when I am trying them in terminal.
Any suggession plz.
Thanks in advance...

5 Years
Discussion Span
Last Post by rubberman

From the bash man page about the read command:

-p prompt
Display prompt on standard error, without a trailing newline, before attempting to read any
input. The prompt is displayed only if input is coming from a terminal.

It may be that since you say it works when running in a terminal, I have to assume that this is not the case when the error occurs? Just how are you running the script then? Please explain in detail.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.