in reply to Re^2: running process from CGI
in thread running process from CGI

OK, different problem now. When you say 'it does not work' when used in backticks, is the file created in the wrong directory, or does it fail to read the input?
It could be that the chdir is affecting the redirection. This will be done by the bourne shell. Try providing the full path name of the input file with your redirection.
Failing that, you could try:
`cd $target;../../progs/<script> < <param input file>`
You are invoking a shell anyway (because of the redirection) so adding a cd won't be any more of an overhead.
If you still have problems then we could run it in a pipe, which is much neater.

Replies are listed 'Best First'.
Re^4: running process from CGI
by kota_rocks (Initiate) on Apr 12, 2007 at 12:51 UTC
    Well ! That is more or less what i had been doing. These are relelant lines from my CGI script.
    `echo -e "$pdbdir\n$pdbdir/$pdbid.new\n" > $pdbdir/hbopt`; `cd $pdbdir ; $progpath/hbplus/hbplus < $pdbdir/hbopt`;
    i'm writing the required input parameters to the file 'hbopt' in the relevant directory. This file is being created without problems. Then i invoke the script as shown by the second line of code. This program either does not run at all, or does not create output file anywhere. There are no error messages in my apache error logs.
      Test $? after the backticks commands and output "$!" if non-zero. You might also try running the cgi script from the command line.
        $? is non-zero, but $! returns undef. thanks so much for you help cdrake !