[lug] named pipe missunderstanding
svqueen at gmail.com
Thu Feb 3 07:48:13 MST 2011
On Wed, Feb 2, 2011 at 6:01 PM, jeffrey.haemer at gmail.com
<jeffrey.haemer at gmail.com> wrote:
> Caveat Programmor (let the programmer beware):
> FIFOs (named pipes) are POSIX IPCs that live in the filesystem name space
> and have standardized semantics.
> However, they're creations of the kernel, which owns and manages the data.
> If you create one in a filesystem that's NFS-mounted, and assume you can
> use it to communicate with a process on another machine, you are asking for
> I have asked for trouble like this before, and reliably found some. :-)
> Probably not the cause of the problem under discussion, but worth a mention
> while we're on this topic.
Just some bash code I've played with in the past. It uses netcat (nc)
and named pipes.
This is a daemon that runs on a remote computer that you want to
execute a command on. (WARNING very insecure, just for fun and demo).
# Listens on port for command and then sends the
# response back
trap "GO=0 ; echo quitting now" 2
while [ $GO -eq 1 ]
nc -l -p 9778 < /tmp/backpipe0 | ./runcmd > /tmp/backpipe0
This is the client that communicates with it from a local computer.
This command takes the double quoted first command line argument and
pipes it to the stdin of a nc client that connects to the server that
is passed as a double quoted second command line argument. The -w1
switch allows the server 1 second to respond with the results of the
command. This should be adjusted for commands that may take a while to
echo $cmd | nc $cmdserver 9778 -w1
Here is the runcmd script
if [ -z $1 ] ; then
More information about the LUG