cgi integration question

Ken ken at hotmail.com
Fri Oct 11 10:22:13 EDT 2002


"Gerhard Häring" <gerhard.haering at opus-gmbh.net> wrote in message
news:slrnaqdmii.e4.gerhard.haering at haering.opus-gmbh.net...
> Ken <ken at hotmail.com> [2002-10-11 13:55 GMT]:
> > "Gerhard Häring" <gerhard.haering at opus-gmbh.net> wrote:
> >> Yeah. As you seem to use Windows (with a b0rken newsreader), you
> >> won't have a 'cat' program. But you will have a 'sort' program,
> >> so you can try the following:
> >>
> >> >>> import os
> >> >>> outf, inf = os.popen2("sort")
> >> >>> print >>outf, "Mark"
> >> >>> print >>outf, "Joe"
> >> >>> print >>outf, "Marvin"
> >> >>> outf.close()
> >> >>> lines = inf.readlines()
> >> >>> inf.close()
> >> >>> print lines
> >> ['Joe\n', 'Mark\n', 'Marvin\n']
> >
> > Will argc[1] = "Mark", argc[2]="Joe" and argc[3]="Marvin" in this
example?
>
> Using commandline parameters will not work for "sort", but you
> can parse them in your own C++ app. On the Python side, just send
> them over with os.popen2, in your C++ app, read them with argc,
> argv.
>
> > Does "lines = inf.readlines()" read out what is exactly printed
> > out from the return value of the main method or does it catch
> > out what is printed out from the cout<< command?
>
> And efficient way to answer this question is to read the
> documentation about readlines(), or just try it out. Yes, the
> lines read with readline() or readlines() will include the line
> termination characters at their end.
>
> > Eg:, if I have a command line:
> >
> > cout<<"hello world"<<"hi"<<endl;
> >
> > will it appear as ['hello world', 'hi'] or ['hello', 'world',
> > 'hi']? will it have '\n' automatically appended to it?
>
> Just try it out.
>
> At this point, I think you should spend some time with the
> documentation for the Python modules involved, and perhaps with a
> Python tutorial too if you don't know the Python basics already.
>
> Also, don't fear playing around with the interactive interpreter
> or small Python scripts. It's the fastest way approach the
> problem.
>
>
> -- Gerhard

Many thanks. I'll try it out and ask more later. :)






More information about the Python-list mailing list