Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
Duplicate stackoverflow.com/questions/15026580/… –  sputnick Feb 22 '13 at 15:05
    
is createdir file present in the remote computer(x.x.x.x)? –  Gaurav Sharma Feb 22 '13 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 '13 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:

remote1:

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.