Running a shell script in a web server as if it was interactive

2

I have a shell script (csh) - I didn't write it so I can't change it now. The script does a lot of parsing of log files, calls other scripts in languages like Perl and Tcl, creates new files and calls executables. It runs nicely from the command line.

I would like to be able to run the script from a HTML form (I can do that), work normally and output the text that usually goes to the terminal to a web browser instead.

I'm on Ubuntu 10.10 and have installed lighttpd 1.4.26. The script just needs one single variable passed to it from the HTML.

It doesn't work properly.

  1. I linked the 10-cgi.conf to conf-enabled. This should enable CGI, it appears to do so.
  2. I commented out the server.username and server.groupname lines in lighttpd.conf. This apparently lets the server run scripts as "root".
  3. I created a small script that takes the query string, parses it and calls the real useful script.

Here are the problems I'm having:

  1. I add pwd and it prints out the correct directory. However it won't actually use that path when writing files with '>'. I need to manually add the entire path for every file access of this nature - why?

  2. There is no PATH defined, so none of the commands like head, tail, grep, ifconfig etc work. I added a hard-coded PATH= , that seems to work but even then some commands simply don't work. I copied the same PATH as the one I have at an interactive shell. Is there a length limit? Why is there no PATH?

  3. Related to all this is that when calling executables, they seem to be confused as to where they are since relative paths ../../ don't work any more.

I have a feeling that this is some kind of user permission or interactive vs non-interactive problem.

One important note is that this will never be on the web, just running locally on a small setup with a few qualified users. Security is not a concern, really.

N00bler

Posted 2011-04-28T19:23:11.563

Reputation: 21

No answers