Window NT: need to allow client to make system call via CGI script

Emile van Sebille emile at fenx.com
Wed Aug 29 23:13:09 EDT 2001


One thing you could do schedule a self-rescheduling at job to iterate
through the batch jobs submitted.  You could set up a long running python
job that spends most of its time sleeping, then wakes and checks the batch
job submission directory.  I've got zope creating and processing batch files
using:

batch = open(batFile, 'w')
for eachCommand in osCommands:
    batch.write("%s\n" % eachCommand)
batch.flush()
batch.close()
os.system(batFile)
if REQUEST.printLoc == "None":
    return
"Submitted!\n\nReprinted:%s\n\nSequences:%s\n\nLines:%s\n\nREQUEST:%s" %
(repr(rePrintSeqs), repr(assignedSeqs), db_repr(lines), repr(REQUEST))
else:
    return "Submitted!"

HTH,


--

Emile van Sebille
emile at fenx.com

---------
"Terry Byrne" <TerryByrne1963 at yahoo.com> wrote in message
news:93d52e82.0108290421.3008647a at posting.google.com...
> Hi, Emile, and thanks for the response.
>
> What I want seems like it should be simple, especially for a language
> as capable as Python. Maybe the answer is some combination of Python
> and batch language or something...
>
> Right now, users on our intranet (production managers at a publishing
> company) fill out an HTML form according to varying production needs.
> Based on their input, an existing Python CGI script builds a DOS batch
> file to run some time-consuming processes on the server. Right now,
> users must use pcAnywhere "remote control" to take over the server,
> start a DOS session, and run the batch file manually. I want to
> eliminate that step. I've been trying to run the batch file on
> submission of the HTML form, to no avail. It seems that because the
> user comes in via HTTP to the CGI, the server's context is unaware of
> the server's own drive structure & path environment variable. Or
> something. Even in my ignorance I see that there are perfectly valid
> security reasons for that.
>
> I wanted to avoid the complications of varying drive mappings etc.
> when building the command lines for the batch file, so the CGI assumes
> the server's local drive structure for paths to exes and input files.
> Because of this assumption, I know, the batch file must run locally. I
> know a truly elegant solution would get the user's drive mapping (if
> exists) to create the proper commands, or maybe it would change drive
> mappings on-the-fly to a standard or something, assuming rights could
> be obtained to do so from the net admin group etc., but that seems too
> elaborate :-)... or maybe that would be easier than I suspect. If so,
> please advise.
>
> Now I'd like some way of running the command lines when the CGI form
> is submitted, or maybe I'd first build the DOS batch file as I am
> right now, then I'd call it. But everything I've tried results in an
> OSError.
>
> Right now when the users run their DOS batch file via pcAnywhere, a
> Python script uses os.popen()to run the custom DOS batch commands
> one-by-one. It evaluates the results returned by the production
> utilities both to stdin and to the utilities' own log files, and the
> script then optionally e-mails specified managers of the results of
> the production processes. (I think that makes sense!) But this whole
> procedure must be started manually via pcAnywhere. I'd really like to
> change that.
>
> Hope this helps. I'm definitely not proud, especially in this crowd.
> Thanks!
>
> -Terry
>
>
> "Emile van Sebille" <emile at fenx.com> wrote in message
news:<9mhsps$2a133$1 at ID-11957.news.dfncis.de>...
> > There's lots of ways of doing it.  Why don't you explain a bit what
you're
> > after?
> >
> > --
> >
> > Emile van Sebille
> > emile at fenx.com
> >
> > ---------
> > "Terry Byrne" <TerryByrne1963 at yahoo.com> wrote in message
> > news:93d52e82.0108280835.1933ba58 at posting.google.com...
> > > All,
> > >
> > > I need to allow clients to run a DOS batch file from an HTML form that
> > > resides on a Windows NT server. Using system(commandline) I always get
> > > an OSError.
> > >
> > > Right now we're using pcAnywhere to log on to the server and run the
> > > batch file that way. I want to make it simpler by using the HTML form.
> > >
> > > The batch file will always be in the same location on the server. I
> > > want to avoid all drive mapping complications by just running the
> > > batch file from an HTML form. Is there a way to do that, or is it
> > > disallowed for security reasons or some other?
> > >
> > > Thanks!




More information about the Python-list mailing list