From: Jeremy Bopp Date: 2010-10-22T05:40:36+09:00 Subject: Re: How to pass/return a string to calling program? On 10/21/2010 3:20 PM, Tony De wrote: > Greetings, > > I have a daemon running (linux server) which listens and receives > service requests from a client, executes the script (which performs the > services) and then returns a message (returned from the script) back to > the client. > > So I'm having some trouble getting a message back to the client. In my > perl scripts a simple "print msg_string" followed by an exit(x) will > pass the msg_string to the daemon which then sends it back to the > client. In ruby I've tried without success: > > puts msg_string > exit > > print msg_string > exit These should definitely work. > at_exit {print msg_string} > exit > > at_exit {puts msg_string} I haven't had a need to use at_exit before, but I suspect that these should also work. Have you tried directly running your scripts by hand to confirm that they output something at all? If they are printing something, try making stdout and stderr synchronous rather than buffered in your scripts: $stdout.sync = $stderr.sync = true -Jeremy