I need to run a report, source file on system 1, on system 2. I’d like to do this in one script, not have a second script to run it.
Now cat script | SSH system2
works fine. But no matter what I’ve tried, it gags on ssh system2 <
SSH system2 “`cat test.script`”
That works for me.
David Both wrote:
Thanks, but that’s pretty much what I’m trying with the HERE document. Trouble is, I have a) an sqlquery, o/p piped into b) awk, which I do as one line, breaking it with terminating \ (to make it readable), followed by c) another sqlquery, and a couple of commands.
The issue is that by trying the HERE doc, or making the whole thing a function, and trying SSH server2 func(), or surrounding the whole thing with $(), none of it works, because it all gags on the “\n\n” in the awk script.
You are probably overlooking that in bash, “here documents” are subject to expansion according rules documented in the bash man page, unless you quote the word you use as the here document delimeter.
That is, try:
ssh system2 <<"EOF"
blah, blah EOF