PDA

View Full Version : rexec and child processes in Perl


BenP
2009-03-07, 18:32
I'm trying to write a Perl script that runs a SAS program on a remote server with user-input parameters from an HTML form. If the SAS program completes quickly enough, I want the results returned as HTML in real time; otherwise I want to display a message and email the user with the results when the SAS program finishes.

I'm trying to fork off a child to make a system call for rexec to run the SAS program, and have the parent wait for either a timeout or a completed program. But it seems like the child doesn't even run the rexec line. It immediately returns -1. Apparently Net::SSH isn't installed so I can't use that instead. I can successfully FTP a SAS config file from the HTML form in the child process.

Any advice on what I might be doing wrong with rexec? It works fine if it's not called in the child. It also works if I run the same command in the command line.

RobUSVI
2009-03-07, 21:18
A bit beyond my comfort zone, but the first things I would check are execution path and permissions (of the to be exed'd process) on the remote side.

ShadowOfGed
2009-03-09, 00:19
I'm not familiar with anything called "rexec." Can you explain that a bit further?

BenP
2009-03-09, 07:02
I'm not familiar with anything called "rexec." Can you explain that a bit further?

Same as exec but can run commands on a remote server, and has options for a username and password.

http://www.rt.com/man/rexec.1.html

Taskiss
2009-03-09, 07:27
The only thing I can suggest is to make sure you can start the process via cron or at or something like that, to make sure it can execute without having a terminal attached to the process. I've run into situations where the app requires a TERM variable set and it isn't set automatically in some cases.

Once you can get it to run via cron, you should be able to fire it up from anything.

ShadowOfGed
2009-03-09, 18:34
What process/web server are you forking FROM? And what platform are you on? There are a host of things that can go wrong during the fork/exec process (presuming you're calling exec in some form). The -1 probably indicates your fork/exec never really got off the ground.