Question/clarification
Hey, just passing by your repo and I wanted to ask how this is different from piping the output of a command into |sh
e.g.,
echo $PWD | awk '{ print "ls "$0 }' ls /home/cadnav
echo $PWD | awk '{ print "ls "$0 }'|sh <output of ls /home/cadnav>
Hi @cadnav,
its quite different; pipe_exec reads any executable binary from standard input whereas piping into sh is limited to reading shell scripts.
What you are doing above is building the shell script ls /home/cadnav; sh will execute this and look for the binary in the $PATH variable. Depending on your system, ls will probably be found inside /bin. Looks similar to pipe exec, but does something quite different and ls must be installed on the system for this to work.
Here is something that pipe_exec can do but executing a shell script can not: Downloading a binary and immediately opening it:
ssh my_sever.eu 'cat $(which ls)' | pipe_exec
I think pipe_exec would also work for shell scripts as long as the hashbang is used, but I have not checked this.
echo $PWD | awk 'BEGIN { print("#! /bin/sh"); print(); } { print "ls "$0 }'
Please close the issue if this answers your question.