LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (http://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   sh script issue. (http://www.linuxquestions.org/questions/solaris-opensolaris-20/sh-script-issue-535827/)

UltraSoul 03-08-2007 07:12 PM

sh script issue.
 
I am not sure whether I contact the correct forum. If not I will stop the query.

I have solaris 10 installed. I have a question about shell command execution.
I want to execute the read shell command in echo string as follows.

echo "input: `read input`"

But the command above failed to execute. I wonder how I do it?

Blinker_Fluid 03-08-2007 07:20 PM

simple script that shows syntax

#!/bin/sh
echo enter something
read INPUT
echo $INPUT


that's how I usually use read.

UltraSoul 03-08-2007 08:20 PM

#xcon
User ID: <<= I does not want the input line change into the next line.
Can you give me some ideas to modify the input format as "User ID: ryan"

ryan
passwd:


Best Regards.

jlliagre 03-09-2007 02:43 PM

I think this is what you are looking for:
Code:

printf "User ID: "
read uid
stty -echo
printf "Password: "
read password
stty echo
printf "userid=$uid, password: $password"


wpn146 03-29-2007 04:31 PM

Quote:

Originally Posted by UltraSoul
I am not sure whether I contact the correct forum. If not I will stop the query.

I have solaris 10 installed. I have a question about shell command execution.
I want to execute the read shell command in echo string as follows.

echo "input: `read input`"

But the command above failed to execute. I wonder how I do it?

I believe the backticked string is executed first, so your prompting "echo" will follow rather than lead the entry of input, and since a "read input" command doesn't return any text, your "Echo" prompt will become very confusing, asking for "input:" after the input has already been expected.

Try:
Code:

read input?"Enter Input:"


All times are GMT -5. The time now is 10:50 PM.