reading command output from shell script

Hi List,

How to read the output of a command executed from a script.

For ex.
sample_scritp.sh
-------------
useradd testuser1
password testuser1
....
.....
--------------
This prompts for "password", and "confirm password", for which i need to give the values from script.

Can anyone pls suggest a way to do this.

Thanks in advance

You will have to use the 'expect' utility for this. You cannot redirect input to the passwd command afaik.

Okey.
Can Shell script directly call Expect code?i.e can we write Expect code as part of the Shell script or we need write it in a seperate file and execute it.
Pls suggest some links for expect.

Regards,
Sri

Here you go: google search for 'man expect'.

Hi All,
I am just learning shell scripting. I have a simple script (test.sh)
# !/bin/sh
echo "Enter your name"
read name
echo "Your name is $name"

in linux terminal I do
echo Tony | ./test.sh

then it prints out "Your name is Tony"

but when I run it through hyperterminal (that I connected from WinXP machine) then it doesn't work.
I'd like to have your help.
Thanks