Your C++ program has nothing else to do then reading the data from stdin (or cin
for C++). It's your decision on the bash shell to create a temporary object with the data and pass it to the process that runs the executable that have been compiled from the C++ source.
Use a bash script like this
myprog << EOF | tail -n+21 | grep ":" >> logfile.log 2> /dev/null
foo
bar
EOF
Please note the exact macth between the end indicator in the last line and behind the <<
.
Here a further example:
Harper@AMSEL ~/Documents
$ cat fff
cat << EOF -b | tail >> logfile.log 2>/dev/null
this text is used
these chars too
EOF
Harper@AMSEL ~/Documents
$ sh ./fff
Harper@AMSEL ~/Documents
$ cat logfile.log
1 this text is used
2 these chars too
Harper@AMSEL ~/Documents
You may have to check what arguments of you command is evaluated locally and what is used with the ssh at the remove machine. Probably the example above helps to isolate the problem from myprog.