473,388 Members | 1,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

cgi subprocess, cannot get output

Hello,

In the following cgi program, I cannot get subprocess output.
I print the header, flush stdout to prepare it to new content,
but variable 'o' is always empty.

Could somebody help me with that?

def main():
print "Content-type: text/html\n\n"
sys.stdout.flush()

if form.has_key('sentence'):
input = form['sentence'].value

o = Popen(['./tinki', input], stdout=PIPE).communicate()[0]
result = cgi.escape(o)

results['xmlfile'] = result
results['sentence'] = input

content['output'] = (output % results)
print template % content
Best regards,
--
Jakub P. Nowak
Apr 25 '06 #1
2 3613
Jakub Piotr Nowak wrote:
Hello,

In the following cgi program, I cannot get subprocess output.
I print the header, flush stdout to prepare it to new content,
but variable 'o' is always empty.

Could somebody help me with that?

def main():
print "Content-type: text/html\n\n"
sys.stdout.flush()

if form.has_key('sentence'):
input = form['sentence'].value

o = Popen(['./tinki', input], stdout=PIPE).communicate()[0]
result = cgi.escape(o)

results['xmlfile'] = result
results['sentence'] = input

content['output'] = (output % results)
print template % content
Best regards,


What kind of script is tinki? I had a bitch of a problem like this with
perl and ended up just writing to a file. No idea why I couldn't get the
stdout.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Apr 26 '06 #2
Dnia 26.04.2006 James Stroud <js*****@ucla.edu> napisał/a:
} Jakub Piotr Nowak wrote:
}> Hello,
}>
}> In the following cgi program, I cannot get subprocess output.
}> I print the header, flush stdout to prepare it to new content,
}> but variable 'o' is always empty.
}>
}> Could somebody help me with that?
}>
}> [...mniam...]
}>
}> Best regards,
}
} What kind of script is tinki? I had a bitch of a problem like this with
} perl and ended up just writing to a file. No idea why I couldn't get the
} stdout.

Tinki is a natural language parser. It takes a sentence as a
command line argument and prints xml file to stdout.

Thanks for the hint, I will try...

Best regards,
--
Jakub P. Nowak
Apr 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Qiangning Hong | last post by:
I decide to seperate my data collection routine from my data analysis and storage program to a seperate process, so I try to use the new subprocess model in Python 2.4. The main program spawns...
5
by: Grant Edwards | last post by:
I'm trying to use the py-gnuplot module on windows, and have been unable to get it to work reliably under Win2K and WinXP. By default, it uses popen(gnuplotcmd,'w'), but in some situations that...
2
by: Jim | last post by:
Hello, I need a program that will traverse a directory tree to ensure that there are unix-style line endings on every file in that tree that is a text file. To tell text files from others I...
12
by: Eric_Dexter | last post by:
I am trying to modify a programming example and I am coming up with two problems... first is that I can't seem to pass along the arguments to the external command (I have been able to do that with...
9
by: Phoe6 | last post by:
Hi all, Consider this scenario, where in I need to use subprocess to execute a command like 'ping 127.0.0.1' which will have a continuous non- terminating output in Linux. # code # This...
12
by: bhunter | last post by:
Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's...
7
by: skunkwerk | last post by:
Hi, i'm trying to call subprocess.popen on the 'rename' function in linux. When I run the command from the shell, like so: rename -vn 's/\.htm$/\.html/' *.htm it works fine... however when I...
4
by: Tobiah | last post by:
I am not sure how to capture the output of a command using subprocess without creating a temp file. I was trying this: import StringIO import subprocess file = StringIO.StringIO() ...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
5
by: thedsadude | last post by:
Hello, I'm launching a script as follows: <code> p = subprocess.Popen() p.wait() </code> If p.py writes to sys.stdout, then it is shown on the console.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.