Let me explain my situation first. I have an alias in .bashrc:
doscript () { ssh root@server$1 -p2202 "bash -s" < ~/scripts/$2 $3; }
I have a script, that basically consists of several actions like:
check current settings
read comment
do actions
write $comment in a file
restart service
So I run a command
doscript server scriptname parameter
However the "read comment" part does not work. Instead of waiting until I enter the comment, it immediately gets executes, adding nothing to the comment file.
Is there a way to enter variable in that case?
readthe input from. what you can do is tossh server "echo \"this is my comment\" > /tmp/commentfile"before you execute your actual script and chage your script to read the comment from the/tmp/commentfileinstead of from thetty.