LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   linux shell program problem (https://www.linuxquestions.org/questions/programming-9/linux-shell-program-problem-502586/)

beanxp 11-17-2006 03:11 PM

linux shell program problem
 
hi,all,
I have a very simple linux shell program, but it can not run properly, can anyone tell me what wrong with the program.
Code:

#!/bin/sh
echo "Is it morning,please anser(Yes/No)"
read timeofday
echo $timeofday

The error message is "': not a valid identifiertimeofday" after I input "Yes" or "No".
Thanks

demon_vox 11-17-2006 03:23 PM

Hi,
I tried your code and it worked fined...
Perhaps you could try commenting the first line to see if that one makes you trouble,but its not very likely.
Or perhaps there is some alias or something defined for the name timeofday. You could try changing the name for that variable to see if it works.

Just some thoughts ;)
Cheers!

matthewg42 11-17-2006 03:36 PM

Works for me:
Code:

$ cat > test.sh
#!/bin/sh
echo "Is it morning,please anser(Yes/No)"
read timeofday
echo $timeofday
$ chmod 755 test.sh
$ ./test.sh
Is it morning,please anser(Yes/No)
No
No



All times are GMT -5. The time now is 01:23 AM.