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 <<EOF
blah, blah
EOF.
Mostly, I have a multiline awk script in the script, with \ at the end of
each line... *but* I think it's seeing "\n" as an eol, and
complaining, of
course.
Suggestions?
mark
Try:
ssh system2 "`cat test.script`"
That works for me.
On 08/09/2016 01:35 PM, m.roth at 5-cent.us wrote:> 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 <<EOF
> blah, blah
> EOF.
>
> Mostly, I have a multiline awk script in the script, with \ at the end of
> each line... *but* I think it's seeing "\n" as an eol, and
complaining, of
> course.
>
> Suggestions?
>
> mark
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos
--
*********************************************************
David P. Both, RHCE
Millennium Technology Consulting LLC
Raleigh, NC, USA
919-389-8678
dboth at millennium-technology.com
www.millennium-technology.com
www.databook.bz - Home of the DataBook for Linux
DataBook is a Registered Trademark of David Both
*********************************************************
This communication may be unlawfully collected and stored by the National
Security Agency (NSA) in secret. The parties to this email do not consent to the
retrieving or storing of this communication and any related metadata, as well as
printing, copying, re-transmitting, disseminating, or otherwise using it. If you
believe you have received this communication in error, please delete it
immediately.
David Both wrote:> Try: > > ssh system2 "`cat test.script`" > > That works for me.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. mark> > On 08/09/2016 01:35 PM, m.roth at 5-cent.us wrote: >> 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 <<EOF >> blah, blah >> EOF. >> >> Mostly, I have a multiline awk script in the script, with \ at the end >> of >> each line... *but* I think it's seeing "\n" as an eol, and complaining, >> of >> course. >> >> Suggestions? >> >> mark >> >> _______________________________________________ >> CentOS mailing list >> CentOS at centos.org >> https://lists.centos.org/mailman/listinfo/centos > > -- > > > ********************************************************* > David P. Both, RHCE > Millennium Technology Consulting LLC > Raleigh, NC, USA > 919-389-8678 > > dboth at millennium-technology.com > > www.millennium-technology.com > www.databook.bz - Home of the DataBook for Linux > DataBook is a Registered Trademark of David Both > ********************************************************* > This communication may be unlawfully collected and stored by the National > Security Agency (NSA) in secret. The parties to this email do not consent > to the > retrieving or storing of this communication and any related metadata, as > well as > printing, copying, re-transmitting, disseminating, or otherwise using it. > If you > believe you have received this communication in error, please delete it > immediately. > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos >
On 08/09/2016 10:35 AM, m.roth at 5-cent.us wrote:> it gags on > ssh system2 <<EOF > blah, blah > EOF. > > Mostly, I have a multiline awk script in the script, with \ at the end of > each lineYou 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
Gordon Messmer wrote:> On 08/09/2016 10:35 AM, m.roth at 5-cent.us wrote: >> it gags on >> ssh system2 <<EOF >> blah, blah >> EOF. >> >> Mostly, I have a multiline awk script in the script, with \ at the end >> of each line > > 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 > EOFActually, the script itself is ksh. However, finally getting to email with my manager, he just did it the simpler way, with a separate script to run it. And the reason I didn't realize that his script was working as designed is that unless I fed /dev/null into his script, rather than send a email, it printed the report to the screen.... mark