Hi all I am new to shell scripting and please help me in this situation.
I have created a shell script named ./remote1 which looks like below.

# ./remote1 file
ssh [email protected] 'bash -s' < ./createdir

Here 'createdir' is another file i had created which is given below

# ./createdir file
echo "give directory name"
read name
mkdir ~/$name

If I run the ./createdir alone in my machine, it will execute without any problem.
If I execute ./remote1, it will not wait for input the data for the 'read' command.Please anyone could help me to solve this problem.
Thanks in advance.

  • Duplicate stackoverflow.com/questions/15026580/… Feb 22, 2013 at 15:05
  • is createdir file present in the remote computer(x.x.x.x)? Feb 22, 2013 at 15:13
  • This works: ssh host "bash -c 'read data; echo \$data'" - I suspect using bash -s does something like block any builtins (eg, read) from using STDIN, but I am not certain.
    – chronitis
    Feb 22, 2013 at 15:15

1 Answer 1


Looks like you want to exec the command via ssh on another machine. Bute there is no one who could give an answer to the read command.

Try to read the name on the local machine and put in a variable like:


echo "give directory name"
read name
ssh [email protected] mkdir ~/$name

I cant test it now, but I think this will execute the mkdir on the remote machine directly vis ssh, without anoter script on it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .