Quantcast
Channel: Perform shell operation through secure shell - Super User
Viewing all articles
Browse latest Browse all 4

Answer by tripleee for Perform shell operation through secure shell

$
0
0

As a direct example of your pseudocode,

scp file remote:/tmp/filessh remote 'cd /tmp; cat file >another; rm another'scp remote:/tmp/another /tmp

Perhaps you want to avoid the use of temprary files; if you can use standard input and standard output for this, you might get away with something like

ssh remote 'remotescriptname'<input >output

... assuming remotescriptname can read standard input, and end up producing the result on standard output. (You will want to prevent noisy commands like make from producing any output on standard output; make -s is your friend.)

You'll notice that you can have an abitrarily complex snippet of shell script between the single quotes. There doesn't need to be a program remotescriptname if you prefer to put the entire command line of the individual commands between the single quotes, like in my first example; but you might want to anyway, because a self-contained script is easier to debug and maintain.


Viewing all articles
Browse latest Browse all 4

Trending Articles