shell

shell script read command is not waiting along with ssh


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 username@x.x.x.x '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.


Solution

  • Thanks all for your great support, I have solved my issue.

    # ./remote1 file<br />
    ssh username@x.x.x.x 'echo "give directory name"';
    read name;
    mkdir ~/$name
    

    This solved my issue simply.