On Thursday, July 9, 2015 at 4:32:28 PM UTC-7, reddyreddy wrote:
>
> Thank you.
> I have one more question to you.
> Instead of passing the file I want to pass line by line as input and write 
> the corresponding output to newline in outputfile.
>
> lines = list(rfile)
> subprocess.call(['gcc',pathnew,'-o','x'])
> L=list()
> for line in lines:
> subprocess.call(["./x"], stdin = line, stdout=list())
>
> Iam trying to do it with for loop but Iam getting the below error.
>  
>
AttributeError: 'str' object has no attribute 'fileno'
> Is there any other way to do this. Thanks in advance.
>

The stdin argument is supposed to be a file handle (something you've done 
an open() on).  Ditto stdout. And for subprocess.call(), you can't set 
these to "PIPE".  You need to to use p=Popen() and then p.communicate(line) 
to do this sort of thing, I think, but I haven't tried this.  It's a little 
lower-level interface than subprocess.call() (literally, because the docs 
make clear that call() calls Popen()).

Another suggestion, btw, for reducing the risk of the submitted program 
doing bad things, is for you to open the file as a string, and look for 
substrings that are obviously bad.  This will only catch the most obvious 
things, and only the ones you know to look for, but it's better than 
accepting uninspected code.

<URL:http://langsec.org/>

/dps




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to