0

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.

1

2 Answers 2

1

The problem is with the remote read. Why don't you execute the read on the local machine, rather than remotely?

For example, you can change your script to:

# ./remote1 file
echo "give directory name"
read name

ssh [email protected] "bash -s" < ./createdir "$name"
Sign up to request clarification or add additional context in comments.

1 Comment

That is an option.But if there is any solution then that would be better.
1

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

# ./remote1 file<br />
ssh [email protected] 'echo "give directory name"';
read name;
mkdir ~/$name

This solved my issue simply.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.