Marko Rauhamaa a écrit :
> Benjamin Watine <[EMAIL PROTECTED]>:
>
>> How can I do this ? I would like a function like that :
>>
>> theFunction ('cat -', stdin=myVar)
>>
>> Another related question : Is there's a limitation of var size ? I
>> would have var up to 10 MB.
>
> import subprocess
> myVar = '*' * 10000000
> cat = subprocess.Popen('cat',shell = True,stdin = subprocess.PIPE)
> cat.stdin.write(myVar)
> cat.stdin.close()
> cat.wait()
>
>
> Marko
>
Thank you Marko, it's exactly what I need.
And if somebody need it : to get the stdout in a var (myNewVar), not in
the shell :
cat = subprocess.Popen('cat', shell = True, stdin = subprocess.PIPE,
stdout=subprocess.PIPE)
cat.stdin.write(myVar)
cat.stdin.close()
cat.wait()
myNewVar = cat.stdout.read()
Is it correct ?
Ben
--
http://mail.python.org/mailman/listinfo/python-list