transparentcow
transparentcow

Reputation: 41

Can you prompt for user input in a shell script that is running remotely?

Say I have a script that will be run on a remote machine. While running, the script computes some value. I want to prompt the user so she can change this value if needed. Is this possible?

I am running the script like: ssh $usr@$machine 'bash -s' < a.sh "param1" "param2"

In a.sh the read alternateValue function call seems to be ignored.

Or can anyone suggest a different approach?

Upvotes: 0

Views: 532

Answers (1)

larsks
larsks

Reputation: 312868

The read statement reads data from stdin, but you are redirecting stdin in your command line with the < operator, so read isn't going to do anything useful.

What if you were first to copy the script over to the remote host, and then run:

ssh $usr@$machine 'bash /path/to/a.sh param1 param2'

Because there is no redirection happening here, read would work without a problem.

Upvotes: 3

Related Questions