Re: running programs from within python

2005-03-09 Thread Steven Bethard
M.N.A.Smadi wrote:
> am getting an error in the script as follows:
>
> NameError: global name 'os' is not defined
>
> however i dont get the same error when running from the python CLI.
> (and yes i am importing the os module)
> Steven Bethard wrote:
> Can you give the full exception message (i.e. copy-paste it from the
> output)?
M.N.A.Smadi top-posted:
this is the full error
Traceback (most recent call last):
 File "./plugin.py", line 60, in ?
   main()
 File "./plugin.py", line 40, in main
   os.system("/root/tmp/bibutils_3.14/isi2xml " + isi_file + " > 
tmp_isi_xml.xml")
NameError: global name 'os' is not defined
Hmmm...  I don't see how you'd get this if you're really importing the 
os module (as you say above).  Are you sure that you have 'import os' at 
the top of plugin.py?  You don't have any conditional wrapped around it 
do you?

STeVe
--
http://mail.python.org/mailman/listinfo/python-list


RE: running programs from within python

2005-03-09 Thread Batista, Facundo
Title: RE: running programs from within python





[James Stroud]


#- import os


He says he did it:


#- > > M.N.A.Smadi wrote:
#- > >> (and yes i am importing the os module)


But he still didn't paste the code here



.    Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA.


La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.



-- 
http://mail.python.org/mailman/listinfo/python-list

Re: running programs from within python

2005-03-09 Thread James Stroud
You should

import os

On Wednesday 09 March 2005 10:06 am, M.N.A.Smadi wrote:
> this is the full error
>
>
> Traceback (most recent call last):
>   File "./plugin.py", line 60, in ?
> main()
>   File "./plugin.py", line 40, in main
> os.system("/root/tmp/bibutils_3.14/isi2xml " + isi_file + " >
> tmp_isi_xml.xml")
> NameError: global name 'os' is not defined
>
> smadi
>
> Steven Bethard wrote:
> > M.N.A.Smadi wrote:
> >> am getting an error in the script as follows:
> >>
> >> NameError: global name 'os' is not defined
> >>
> >> however i dont get the same error when running from the python CLI.
> >> (and yes i am importing the os module)
> >
> > Can you give the full exception message (i.e. copy-paste it from the
> > output)?
> >
> > STeVe

-- 
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running programs from within python

2005-03-09 Thread M.N.A.Smadi
this is the full error
Traceback (most recent call last):
 File "./plugin.py", line 60, in ?
   main()
 File "./plugin.py", line 40, in main
   os.system("/root/tmp/bibutils_3.14/isi2xml " + isi_file + " > 
tmp_isi_xml.xml")
NameError: global name 'os' is not defined

smadi
Steven Bethard wrote:
M.N.A.Smadi wrote:
am getting an error in the script as follows:
NameError: global name 'os' is not defined
however i dont get the same error when running from the python CLI. 
(and yes i am importing the os module)

Can you give the full exception message (i.e. copy-paste it from the 
output)?

STeVe

--
http://mail.python.org/mailman/listinfo/python-list


Re: running programs from within python

2005-03-09 Thread Steven Bethard
M.N.A.Smadi wrote:
am getting an error in the script as follows:
NameError: global name 'os' is not defined
however i dont get the same error when running from the python CLI. (and 
yes i am importing the os module)
Can you give the full exception message (i.e. copy-paste it from the 
output)?

STeVe
--
http://mail.python.org/mailman/listinfo/python-list


RE: running programs from within python

2005-03-09 Thread Batista, Facundo
Title: RE: running programs from within python





[M.N.A.Smadi]


#- am getting an error in the script as follows:
#- 
#- NameError: global name 'os' is not defined


What script? 


Please paste it here. If it's more than 20 lines, trim it until you find the smaller script that has the error.


.    Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA.


La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.



-- 
http://mail.python.org/mailman/listinfo/python-list

Re: running programs from within python

2005-03-09 Thread M.N.A.Smadi
am getting an error in the script as follows:
NameError: global name 'os' is not defined
however i dont get the same error when running from the python CLI. (and 
yes i am importing the os module)

is this a bug in python 2.3 (the one am currently using)
thanks
m.smadi
Steven Bethard wrote:
M.N.A.Smadi wrote:
M.N.A.Smadi wrote:
hi;
in general: how can i pass a string containing a concatenated 
sequcne of command line arguments to a unix system CLI?

i guess i will answer myself:
import os
os.system(string)

Also worth noting is that if you're using Python 2.4, you might want 
to look at the subprocess module, which replaces many of the older 
os.* calls with a more flexible interface.  For the os.system 
replacement, see:

http://docs.python.org/lib/node235.html
STeVe

--
http://mail.python.org/mailman/listinfo/python-list


Re: running programs from within python

2005-03-09 Thread Steven Bethard
M.N.A.Smadi wrote:
M.N.A.Smadi wrote:
hi;
in general: how can i pass a string containing a concatenated sequcne 
of command line arguments to a unix system CLI?

i guess i will answer myself:
import os
os.system(string)
Also worth noting is that if you're using Python 2.4, you might want to 
look at the subprocess module, which replaces many of the older os.* 
calls with a more flexible interface.  For the os.system replacement, see:

http://docs.python.org/lib/node235.html
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


RE: running programs from within python

2005-03-09 Thread Batista, Facundo
Title: RE: running programs from within python





[M.N.A.Smadi]


#- i guess i will answer myself:
#- import os
#- os.system(string)


If you have Py2.4, it's better to use subprocess().


.    Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



-- 
http://mail.python.org/mailman/listinfo/python-list

Re: running programs from within python

2005-03-09 Thread M.N.A.Smadi
M.N.A.Smadi wrote:
hi;
in general: how can i pass a string containing a concatenated sequcne 
of command line arguments to a unix system CLI?

my specific problem:
i have an executable that is called xyz (written in C if that matters) 
that i cannot modify, which prints it is text output to the screen and 
takes an input as t.txt.
on a unix terminal, i do the ./xyz t.txt > tmp.txt
so that the tmp.txt will contain the output of the xyz executable

i tried the following but it did not work
import os
os.execl("./xyz","t.txt > tmp.txt") #the thing just hangs there
i aslo tried
os.execl("./xyz","t.txt") # but it does not output anything to the 
screen either, hangs there too

any suggestions?
thanks
m.smadi
i guess i will answer myself:
import os
os.system(string)
!!
--
http://mail.python.org/mailman/listinfo/python-list