🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #1603

Re: Ejecutar programas externos con Python

#1603
From: forodejazz
Date: Mon, 26 Sep 2005 06:43
32 lines
1920 bytes
En la lista de correo python-es (1) seguro que encuentras la solución,
esa pregunta creo recordar que ha salido muchas veces.

(1) http://listas.aditel.org/archivos/python-es/

Copio y pego de la documentación de Python, módulo popen2:

popen2( cmd[, bufsize[, mode]])

Executes cmd as a sub-process. Returns the file objects (child_stdout,
child_stdin).

popen3( cmd[, bufsize[, mode]])

Executes cmd as a sub-process. Returns the file objects (child_stdout,
child_stdin, child_stderr).

popen4( cmd[, bufsize[, mode]])

Executes cmd as a sub-process. Returns the file objects
(child_stdout_and_stderr, child_stdin). New in version 2.0.


Ejemplo:

import popen2

(salida, entrada) = popen2.popen2("ls")

for a in salida:
    print a
Technical Details
Message-ID: <1127716989.391327.33150@g47g2000cwa.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail
References: <dgul8d$b18$1@nsnmpen3-gest.nuria.telefonica-data.net>

Show Full Headers
Complete Article Headers
X-Google-Thread: f86c8,9ad54b394a4b9194
X-Google-Attributes: gidf86c8,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail
From: forodejazz@gmail.com
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Ejecutar programas externos con Python
Date: 25 Sep 2005 23:43:09 -0700
Organization: http://groups.google.com
Lines: 33
Message-ID: <1127716989.391327.33150@g47g2000cwa.googlegroups.com>
References: <dgul8d$b18$1@nsnmpen3-gest.nuria.telefonica-data.net>
NNTP-Posting-Host: 212.49.161.156
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1127716994 14188 127.0.0.1 (26 Sep 2005 06:43:14 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 26 Sep 2005 06:43:14 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Opera/8.50 (Windows NT 5.1; U; es-ES),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: g47g2000cwa.googlegroups.com; posting-host=212.49.161.156;
   posting-account=P4keSg0AAAChwZeUOhTuPz6zBKFyRU29