0
I have a process that dumps some zipped output to the stdout. What I do with this output is pipe and send it through an SSH tunnel to another machine where it is dumped to a file.
Like so:
/usr/bin/myapp | ssh root@remotemachine "cat > /path/to/output/file.gz"
when I ssh
to the machine and invoke this line, everything goes fine. But when I put this command in a shell script like
#!/bin/sh
APP=/usr/bin/myapp
OPTS=--gzip
OUTPUT= "| ssh root@remotemachine \"cat > /path/to/output/file.gz\""
$APP $OPTS $OUTPUT
And then invoke the script, I see garbage on the console, which I can only assume it is the output of myapp
, and then this
Unknown parameter '|'
Unknown parameter 'ssh'
Unknown parameter 'root@remotemachine'
Unknown parameter '"cat'
Unknown parameter '>'
Unknown parameter '/path/to/output/file.gz"'
I am guessing that shell sent the $OUTPUT
section as an argument to myapp
instead of acting on them. So, these "Unknown parameter" were coming from myapp
not from the shell.
How I can fix this?
have you tried /bin/bash instead of /bin/sh ? – Sirex – 2018-04-30T21:20:50.613
No, the system I am working on does not have bash. I need to restrict the work to ash – hebbo – 2018-04-30T21:21:43.307
Then you shouldn't use
bash
as a tag. – AFH – 2018-04-30T21:25:30.107ok...removed it. But I was wondering if my problem is not specific to ash and may in fact happen in bash too. So, I wanted to reach a wider audience. Also, at this point I am not where the problem is. – hebbo – 2018-04-30T21:27:13.463