Where is my pasted input going?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I am copying and pasting sequences of shell commands into my terminal emulator, and I am confused by the behaviour.
- When I paste the single line
ssh user@remote "echo foo"; echo baz
the computer does what I expect. It runs the SSH command and then echoes something after I have finished my SSH session. - When I paste the same thing as a multiple-line command, however, this does not happen.
ssh user@remote "echo foo"
I still get the SSH session, but the
echo bazecho baz
completely disappears. No command is run. - This seems to be something to do with SSH, at least. Because replacing SSH with something else yields the behaviour that I was actually expecting.
Both commands run when I paste this, for example:echo foo
echo baz
So what is happening? Where is the pasted input going? Why is the echo command not executed by anything? How is this related to SSH?
(By the way: I know of Ctrl+X, Ctrl+E method, but sometimes, especially when using terminal emulators on Windows, this won't work out of the box.)
ssh clipboard
add a comment |Â
up vote
1
down vote
favorite
I am copying and pasting sequences of shell commands into my terminal emulator, and I am confused by the behaviour.
- When I paste the single line
ssh user@remote "echo foo"; echo baz
the computer does what I expect. It runs the SSH command and then echoes something after I have finished my SSH session. - When I paste the same thing as a multiple-line command, however, this does not happen.
ssh user@remote "echo foo"
I still get the SSH session, but the
echo bazecho baz
completely disappears. No command is run. - This seems to be something to do with SSH, at least. Because replacing SSH with something else yields the behaviour that I was actually expecting.
Both commands run when I paste this, for example:echo foo
echo baz
So what is happening? Where is the pasted input going? Why is the echo command not executed by anything? How is this related to SSH?
(By the way: I know of Ctrl+X, Ctrl+E method, but sometimes, especially when using terminal emulators on Windows, this won't work out of the box.)
ssh clipboard
The conclusion that you have jumped to, upon which you have then based the question, is wrong.
â JdeBP
Jun 25 at 16:52
Do you mean specifically, that I'm referring tossh
as the source of this behavior? It might be one of the cases, and since I didn't search for any other, I've decided to leave it as an example. Or do you refer to "copy-pasting" instead of "evaluating pasted"?
â mjktfw
Jun 25 at 17:05
You've jumped to the conclusion that stuff is not being pasted, and then asked why pasting breaks. It is not actually the case in the first place that the input is not being pasted. So this question is based upon a false assumption from the title onwards. Where is this pasted input going? is by far a better question.
â JdeBP
Jun 25 at 17:15
There you go. The answer to this is actually fairly straightforward, Let's see whether anyone answers it.
â JdeBP
Jun 25 at 17:30
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am copying and pasting sequences of shell commands into my terminal emulator, and I am confused by the behaviour.
- When I paste the single line
ssh user@remote "echo foo"; echo baz
the computer does what I expect. It runs the SSH command and then echoes something after I have finished my SSH session. - When I paste the same thing as a multiple-line command, however, this does not happen.
ssh user@remote "echo foo"
I still get the SSH session, but the
echo bazecho baz
completely disappears. No command is run. - This seems to be something to do with SSH, at least. Because replacing SSH with something else yields the behaviour that I was actually expecting.
Both commands run when I paste this, for example:echo foo
echo baz
So what is happening? Where is the pasted input going? Why is the echo command not executed by anything? How is this related to SSH?
(By the way: I know of Ctrl+X, Ctrl+E method, but sometimes, especially when using terminal emulators on Windows, this won't work out of the box.)
ssh clipboard
I am copying and pasting sequences of shell commands into my terminal emulator, and I am confused by the behaviour.
- When I paste the single line
ssh user@remote "echo foo"; echo baz
the computer does what I expect. It runs the SSH command and then echoes something after I have finished my SSH session. - When I paste the same thing as a multiple-line command, however, this does not happen.
ssh user@remote "echo foo"
I still get the SSH session, but the
echo bazecho baz
completely disappears. No command is run. - This seems to be something to do with SSH, at least. Because replacing SSH with something else yields the behaviour that I was actually expecting.
Both commands run when I paste this, for example:echo foo
echo baz
So what is happening? Where is the pasted input going? Why is the echo command not executed by anything? How is this related to SSH?
(By the way: I know of Ctrl+X, Ctrl+E method, but sometimes, especially when using terminal emulators on Windows, this won't work out of the box.)
ssh clipboard
edited Jun 25 at 17:29
JdeBP
27.9k459133
27.9k459133
asked Jun 25 at 14:23
mjktfw
142
142
The conclusion that you have jumped to, upon which you have then based the question, is wrong.
â JdeBP
Jun 25 at 16:52
Do you mean specifically, that I'm referring tossh
as the source of this behavior? It might be one of the cases, and since I didn't search for any other, I've decided to leave it as an example. Or do you refer to "copy-pasting" instead of "evaluating pasted"?
â mjktfw
Jun 25 at 17:05
You've jumped to the conclusion that stuff is not being pasted, and then asked why pasting breaks. It is not actually the case in the first place that the input is not being pasted. So this question is based upon a false assumption from the title onwards. Where is this pasted input going? is by far a better question.
â JdeBP
Jun 25 at 17:15
There you go. The answer to this is actually fairly straightforward, Let's see whether anyone answers it.
â JdeBP
Jun 25 at 17:30
add a comment |Â
The conclusion that you have jumped to, upon which you have then based the question, is wrong.
â JdeBP
Jun 25 at 16:52
Do you mean specifically, that I'm referring tossh
as the source of this behavior? It might be one of the cases, and since I didn't search for any other, I've decided to leave it as an example. Or do you refer to "copy-pasting" instead of "evaluating pasted"?
â mjktfw
Jun 25 at 17:05
You've jumped to the conclusion that stuff is not being pasted, and then asked why pasting breaks. It is not actually the case in the first place that the input is not being pasted. So this question is based upon a false assumption from the title onwards. Where is this pasted input going? is by far a better question.
â JdeBP
Jun 25 at 17:15
There you go. The answer to this is actually fairly straightforward, Let's see whether anyone answers it.
â JdeBP
Jun 25 at 17:30
The conclusion that you have jumped to, upon which you have then based the question, is wrong.
â JdeBP
Jun 25 at 16:52
The conclusion that you have jumped to, upon which you have then based the question, is wrong.
â JdeBP
Jun 25 at 16:52
Do you mean specifically, that I'm referring to
ssh
as the source of this behavior? It might be one of the cases, and since I didn't search for any other, I've decided to leave it as an example. Or do you refer to "copy-pasting" instead of "evaluating pasted"?â mjktfw
Jun 25 at 17:05
Do you mean specifically, that I'm referring to
ssh
as the source of this behavior? It might be one of the cases, and since I didn't search for any other, I've decided to leave it as an example. Or do you refer to "copy-pasting" instead of "evaluating pasted"?â mjktfw
Jun 25 at 17:05
You've jumped to the conclusion that stuff is not being pasted, and then asked why pasting breaks. It is not actually the case in the first place that the input is not being pasted. So this question is based upon a false assumption from the title onwards. Where is this pasted input going? is by far a better question.
â JdeBP
Jun 25 at 17:15
You've jumped to the conclusion that stuff is not being pasted, and then asked why pasting breaks. It is not actually the case in the first place that the input is not being pasted. So this question is based upon a false assumption from the title onwards. Where is this pasted input going? is by far a better question.
â JdeBP
Jun 25 at 17:15
There you go. The answer to this is actually fairly straightforward, Let's see whether anyone answers it.
â JdeBP
Jun 25 at 17:30
There you go. The answer to this is actually fairly straightforward, Let's see whether anyone answers it.
â JdeBP
Jun 25 at 17:30
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Try pasting this:
ssh user@host 'read foo; echo ">>$foo<<"'
echo bar
You will see >>echo bar<<
as output from the echo
on the server.
This means that ssh
will eat the pasted data on its standard input, as if you had done
echo 'echo bar' | ssh user@host 'read foo; echo ">>$foo<<"'
The solution to this, apart from never pasting shell commands into the terminal to run them, is to use ssh -n
, which will redirect /dev/null
into ssh
:
ssh -n user@host 'echo foo'
echo bar
Unfortunately I don't know the mechanics of pasting, so I can't say anything clever about why the pasted data ends up on the standard input stream of ssh
, but I'm guessing it has to do with the stream being inherited from the interactive shell (which reads commands from standard input).
Using ssh -n
is also the solution (or at least a solution) to the issue of
while read something; do
ssh user@host 'somecommand'
done <inputfile
Here, the loop will only run once since ssh
eats the data from inputfile
.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Try pasting this:
ssh user@host 'read foo; echo ">>$foo<<"'
echo bar
You will see >>echo bar<<
as output from the echo
on the server.
This means that ssh
will eat the pasted data on its standard input, as if you had done
echo 'echo bar' | ssh user@host 'read foo; echo ">>$foo<<"'
The solution to this, apart from never pasting shell commands into the terminal to run them, is to use ssh -n
, which will redirect /dev/null
into ssh
:
ssh -n user@host 'echo foo'
echo bar
Unfortunately I don't know the mechanics of pasting, so I can't say anything clever about why the pasted data ends up on the standard input stream of ssh
, but I'm guessing it has to do with the stream being inherited from the interactive shell (which reads commands from standard input).
Using ssh -n
is also the solution (or at least a solution) to the issue of
while read something; do
ssh user@host 'somecommand'
done <inputfile
Here, the loop will only run once since ssh
eats the data from inputfile
.
add a comment |Â
up vote
1
down vote
accepted
Try pasting this:
ssh user@host 'read foo; echo ">>$foo<<"'
echo bar
You will see >>echo bar<<
as output from the echo
on the server.
This means that ssh
will eat the pasted data on its standard input, as if you had done
echo 'echo bar' | ssh user@host 'read foo; echo ">>$foo<<"'
The solution to this, apart from never pasting shell commands into the terminal to run them, is to use ssh -n
, which will redirect /dev/null
into ssh
:
ssh -n user@host 'echo foo'
echo bar
Unfortunately I don't know the mechanics of pasting, so I can't say anything clever about why the pasted data ends up on the standard input stream of ssh
, but I'm guessing it has to do with the stream being inherited from the interactive shell (which reads commands from standard input).
Using ssh -n
is also the solution (or at least a solution) to the issue of
while read something; do
ssh user@host 'somecommand'
done <inputfile
Here, the loop will only run once since ssh
eats the data from inputfile
.
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Try pasting this:
ssh user@host 'read foo; echo ">>$foo<<"'
echo bar
You will see >>echo bar<<
as output from the echo
on the server.
This means that ssh
will eat the pasted data on its standard input, as if you had done
echo 'echo bar' | ssh user@host 'read foo; echo ">>$foo<<"'
The solution to this, apart from never pasting shell commands into the terminal to run them, is to use ssh -n
, which will redirect /dev/null
into ssh
:
ssh -n user@host 'echo foo'
echo bar
Unfortunately I don't know the mechanics of pasting, so I can't say anything clever about why the pasted data ends up on the standard input stream of ssh
, but I'm guessing it has to do with the stream being inherited from the interactive shell (which reads commands from standard input).
Using ssh -n
is also the solution (or at least a solution) to the issue of
while read something; do
ssh user@host 'somecommand'
done <inputfile
Here, the loop will only run once since ssh
eats the data from inputfile
.
Try pasting this:
ssh user@host 'read foo; echo ">>$foo<<"'
echo bar
You will see >>echo bar<<
as output from the echo
on the server.
This means that ssh
will eat the pasted data on its standard input, as if you had done
echo 'echo bar' | ssh user@host 'read foo; echo ">>$foo<<"'
The solution to this, apart from never pasting shell commands into the terminal to run them, is to use ssh -n
, which will redirect /dev/null
into ssh
:
ssh -n user@host 'echo foo'
echo bar
Unfortunately I don't know the mechanics of pasting, so I can't say anything clever about why the pasted data ends up on the standard input stream of ssh
, but I'm guessing it has to do with the stream being inherited from the interactive shell (which reads commands from standard input).
Using ssh -n
is also the solution (or at least a solution) to the issue of
while read something; do
ssh user@host 'somecommand'
done <inputfile
Here, the loop will only run once since ssh
eats the data from inputfile
.
edited Jun 25 at 22:06
answered Jun 25 at 19:24
Kusalananda
101k13199312
101k13199312
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451776%2fwhere-is-my-pasted-input-going%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
The conclusion that you have jumped to, upon which you have then based the question, is wrong.
â JdeBP
Jun 25 at 16:52
Do you mean specifically, that I'm referring to
ssh
as the source of this behavior? It might be one of the cases, and since I didn't search for any other, I've decided to leave it as an example. Or do you refer to "copy-pasting" instead of "evaluating pasted"?â mjktfw
Jun 25 at 17:05
You've jumped to the conclusion that stuff is not being pasted, and then asked why pasting breaks. It is not actually the case in the first place that the input is not being pasted. So this question is based upon a false assumption from the title onwards. Where is this pasted input going? is by far a better question.
â JdeBP
Jun 25 at 17:15
There you go. The answer to this is actually fairly straightforward, Let's see whether anyone answers it.
â JdeBP
Jun 25 at 17:30