[PIPython] os.system

Carlo C8E Miron carlo.miron
Gio 23 Giu 2005 19:19:28 CEST


Il 23/06/05, Giovanni Dall'Olio<dalloliogm a fastwebnet.it> ha scritto:
> Salve a tutti,
> scusate ho una domanda da principiante su os.system, ho cercato un po' per
> conto mio ma non sono riuscito a risolvere.
> 
> Come si cattura l'output di questa funzione?

Non si puo'.

> Ad esempio, a=os.system('ls') mi stampa su schermo il contenuto della
> directory in cui ho lanciato il comando, ma mi restituisce come valore '0'.

Il valore di ritorno (lo stato di errore, nullo in questo caso).

> A me invece naturalmente interessa salvare quello che viene stato stampato
> nella variabile a.

Immagino che con questa frase intendi dire che vuoi catturare l'output
del comando.
bene, se usi python 2.4, guardati::

>>> help("subprocess")

alternativamente, con python piu' vecchiotti su OS posix-like puoi usare::

>>> help("command")

se invece insisti ad usare vecchi python su piattaforme non standard ;)
allora guardati

>>> help("popen2")

> Qualcuno può aiutarmi? Grazie.

HTH

> p.s. so che in questo caso potrei usare os.listdir(), però in realtà devo
> lanciare un programma (os.system("chr_subseq chr1.fa 0 100")) all'interno
> dello script e lavorare sull'output.

HAND,
(c)

-- 
Disclaimer:
If I receive a message from you, you are agreeing that:
1. I am by definition, "the intended recipient".
2. All information in the email is mine to do with as I see fit and
 make such financial profit, political mileage, or good joke as it
 lends itself to. In particular, I may quote it on USENET or the WWW.
3. I may take the contents as representing the views of your company.
4. This overrides any disclaimer or statement of confidentiality that
 may be included on your message.


More information about the Python mailing list