[Tutor] Python popen command using cat > textfile .... how to terminate

vince spicer vinces1979 at gmail.com
Fri May 15 00:28:33 CEST 2009


Take a peak at commands.getoutput


EX:

import commmands

ls = commands.getoutput("ls- ls")

Vince

On Thu, May 14, 2009 at 3:50 PM, MK <lopoff at gmx.net> wrote:

> Hi there,
>
> i am using this code to send an "cat > ThisIsMyUrl" with popen.
> Of cos cat now waits for the CTRL+D command.
> How can i send this command ?
>
> def console_command(cmd):
>        print cmd
>        console = os.popen(cmd,"r")
>        output = console.read()
>        console.close()
>        return output
>
> command="cat > " + working_dir + "/" + subdir + "www.thisismyurl.com"
> console_command(command)
>
>
> Thank you.
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090514/6f9a80d2/attachment.htm>


More information about the Tutor mailing list