Exec`ing external programs
Grant Edwards
grante at visi.com
Sat Nov 23 21:56:02 EST 2002
In article <uu0e96366cek50 at corp.supernews.com>, adrian at twistedliving.com wrote:
> import os,sys
>
> a = open('host_list', 'r')
> for host in a.readlines():
> os.system('xterm -e atl.py %h &',%(host))
>
> What I`m trying to do is read a list of hostnames and for each one
> open an xterm and exec atl.py with host as an argument. I am unable
> to background the job, so It hangs until I close the first window.
My guess: Each of the strings returned by readlines contains a newline at
the end. The shell sees that newline (which is before the ampersand) and
runs the command in the foreground.
> However if I set a to a list of hostnames inside the script, it
> functions correctly, but fails when reading from a file.
Here's a hint: Since you know it works when 'a' is a hand-coded list of
strings, and fails when a.readline() is used, take a careful look at the
difference between the 'host' values in the two cases.
--
Grant Edwards grante Yow! Are you guys lined up
at for the METHADONE PROGRAM
visi.com or FOOD STAMPS??
More information about the Python-list
mailing list