0

I want to copy a file to clipboard and then execute it as we do with "ctrl+shift+v", but the copy and paste on line command.

In my case I can't just run a .sh. I have to copy and paste.

I want to connect to ssh and run a command. When I use paste, it works.

I want to see what is going on the terminal, not just send a script to run.

No keyboard keys, just command line.

Vitor Abella
  • 7,537
  • Your question is quite unclear, even with the recent edit. Do you want to connect from a command line on one machine with no GUI, to the cli on another machine via ssh, and run a series of commands? Are these commands already in a file? – Arronical Sep 15 '16 at 10:45

2 Answers2

3

I am not sure whether I understand what you are trying to achieve, but you can easily run long commands or scripts without storing them as a file by using Bash's command editor.

Press Ctrl+X, then Ctrl+E. This will bring up your default editor, usually nano.

In here you can now easily paste the commands or the full script you want to run.

When you're finished, exit nano saving the changes by pressing Ctrl+X ("Exit"), then answer Y (or whatever letter represents "Yes" in your locale) when asked whether to "Save modified buffer". Then press Enter to accept the proposed temporary file name.

As soon as the editor terminates, Bash will run the temporary script and then delete it afterwards.

Byte Commander
  • 107,489
0

The easiest way would be to send file straight to "sh" without using the clipboard:

sh < file.sh

Or alternatively, to run the file without spawning a new process:

`cat file.sh`

If you really need to use the clipboard, refer to A command-line clipboard copy and paste utility?

Janek
  • 101