tags:

views:

471

answers:

2

I am trying to simulate a a network consisting of several clients and servers. I have written node.py which contains client-server code. I want to run multiple instances node.py. But I don't want to do it manually so I have written another file spawn.py which spawns multiple instances of node.py using fork and exec. However, I need to run each instance of node.py on different terminal(shell) so that I can easily debug what is happening inside each node. How can we do that? Please help.

EDIT : I am working on linux and using python 2.5 and I want to run all processes on the same box

+1  A: 
shell #1:
for p in 1 2 3 4 5
do
    python node.py > $p.log 2>&1
done


shell #2:
tail -F 1.log 

shell #3:
tail -F 2.log 

etc...
prime_number
+1  A: 

If you want "real" (pseudo-;-) terminals, and are using X11 (almost every GUI interface on Linux does;-), you could exec xterm -e python node.py instead of just python node.py -- substitute for xterm whatever terminal emulator program you prefer, of course (I'm sure they all have command-line switches equivalent to good old xterm's -e, to specify what program they should run!-).

Alex Martelli
@alex , thanks a lot .. but one more problemxterm -e python.py just opens single terminalif i write a shell script like thisxterm -e python.py 101 xterm -e python.py 102it opens only 1 terminal waits for the prog to finish and then opens second terminal :( How to open all terminals at a time ?
atv
Denis Otkidach