[Zope] Why doesn't os.system(command) work?

Thomas Bennett bennetttm at appstate.edu
Fri Aug 17 10:08:56 EDT 2007


You probably want NT Script.  We use that on our public PCs in the library.  
We have CDs in a tower and use NT Script to map a CD and a drive from a 
server that has an executable to access the CD or run the executable from the 
client machine.  Every machine has NT Script installed.  In 1995 when we 
started using this script I was able to license something like 200 licenses 
for about $250.  The link to PC World to download it says its $20 now and I 
can't even find it on the creators WEB site any more although the 30 day 
trial can be downloaded from PC World.

For a Windows app its pretty neat, has a nice little debugger built in.

For use from a web link we use the extension .prg on all of our nt scripts and 
associate that extension with ntscript.exe.  This is the script for opening 
notepad is a dtml document named notepad.prg.

<dtml-call "RESPONSE.setHeader('Content-Type', 'application/x-ntscript')">
sub main<dtml-var my_return>shell "\windows\notepad.exe" <dtml-var 
my_return>endsub

<dtml-var my_return> is a Script (Python) that contains only:

print "\r"
return printed

This was the only way to get the script to work, using carriage returns in the 
script did not work.

This script {force} maps drives S and T to two directories on server1 then 
starts a local application my_app.exe and that executable's parameters to use 
drive s and t for its data.

<dtml-call "RESPONSE.setHeader('Content-Type', 'application/x-ntscript')">
sub main<dtml-var my_return>$x$=netuse "S:" "\\server1\arev" {force}<dtml-var 
my_return>$x$=netuse "T:" "\\server1\arev2" {force}<dtml-var my_return>shell 
"C:\my_dir\AREVWin\my_app.EXE -c~\ARVW.mnu -t~\bib.trl -aAREV -pS:
\AREV_C\AREV1.D01 -qT:\AREV_C\AREV1.D02" {maximize}<dtml-var my_return>endsub


This method of running local applications from the WEB can be very dangerous 
if another WEB site has an NTScript source on the WEB with a .prg extension 
and the source something like 

<dtml-call "RESPONSE.setHeader('Content-Type', 'application/x-ntscript')">
sub main<dtml-var my_return>shell "fdisk.exe" <dtml-var my_return>endsub

Thomas



On Friday 17 August 2007 03:58, Reinoud van Leeuwen wrote:
> On Thu, Aug 16, 2007 at 10:40:45PM -0700, rieh25 wrote:
> > I think it's finding the programm because I'm using the complete path.
> > And when I test it using the wrong programm name, it returns a 1. But
> > instead, when I pass it the right name, it just hangs. In the task
> > manager there is an entry for the program, but it doesn't seem to
> > execute. Thanks for the help.
>
> How is your Zope running? If it is running as a system service it has
> nothing to do with the current logged on user that has a desktop open. So
> Windows will not show notepad on the desktop...
> The question is: what is the problem you are trying to solve with this?
> Why should the webserver open a notepad? Try playing with a commandline
> program that does something usefull but does not need interaction (a batch
> file or something like that)

-- 
====================================================================
Thomas McMillan Grant Bennett		Appalachian State University
Operations & Systems Analyst		P O Box 32026
University Library				Boone, North Carolina 28608
(828) 262 6587

They say a picture is worth a thousand words.  As videos could be 25 pictures 
per second and might last several minutes, how many words is that? 
- Linux Journal, July 2007

Library Systems Help Desk: http://www.library.appstate.edu/help/
====================================================================


More information about the Zope mailing list