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?
bashas a tag.