cmcmillo has asked for the wisdom of the Perl Monks concerning the following question:

I want to open a named pipe to a running Daemon server. I don't want t +o start the server when I open a pipe to it. I just want to be able t +o write data to it while its running. In other words: open(HANDLE, "|running_server"); print HANDLE "DATA\n"; close(HANDLE); I know one way of writing to the mail server is by using a named pipe: + open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq") or die "Can't fork for sendmail: !\n"; Question: Does anyone know how I could do this? Thanks

Replies are listed 'Best First'.
Re: Opening a named pipe to a daemon
by naikonta (Curate) on Jun 29, 2007 at 03:08 UTC
    You don't generally talk with pipe to daemons, instead, you communicate with them through socket. The IO::Socket is generally use as the basic building block for client-server communication, especially if the server is a custom beast, non-standard Internet server. If this is not the case, check CPAN if there's a module that provides client interface to your daemon.

    The fact that you can do that with sendmail because it does provide the interface, doesn't mean it works generally for other daemons. You have to be exactly sure how your daemon works. What kind of daemon is it, by the way?


    Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Re: Opening a named pipe to a daemon
by jbert (Priest) on Jun 29, 2007 at 06:46 UTC
    Your sendmail example isn't what I'd call a named pipe.

    The open(SENDMAIL, "|/usr/lib/sendmail...") is actually starting a new sendmail process, which will read an email from it's standard input, then write it to the mail queue and then exit. When you print to the SENDMAIL filehandle you are writing to the standard input of this new process.

    The rest of the mail system (which might include a long-running daemon or might not) will at some point notice and handle this new mail item.

    There might be a way to do what you want if you're more specific about what you want to do (which daemon, etc).

Re: Opening a named pipe to a daemon
by jeanluca (Deacon) on Jun 30, 2007 at 06:43 UTC
    My guess would be that you could do something like
    open OUT,">&$some_name" ;
    I have to add that I'm not sure that this is going to work or is what you want, but at least you can try!

    LuCa