1

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

3
  • "run each instance of node.py on different terminal(shell)" Please show how you would do this "manually" from the command line or with a shell script. I'm unclear on what you're talking about. Commented Nov 25, 2009 at 11:48
  • @Lott , if i want to start 3 nodes , I type 'python node.py <port-no>' on 3 different terminals. I want to do the same thing either using shell script or using another python program spawn.py. Commented Nov 25, 2009 at 14:36
  • @atv: So you can't do this from a single terminal manually? You can't use RSH or SSH or PUTTY to do this? Commented Nov 25, 2009 at 16:51

2 Answers 2

1

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!-).

Sign up to request clarification or add additional context in comments.

1 Comment

@alex , thanks a lot .. but one more problem xterm -e python.py just opens single terminal if i write a shell script like this xterm -e python.py 101 xterm -e python.py 102 it opens only 1 terminal waits for the prog to finish and then opens second terminal :( How to open all terminals at a time ?
0
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...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.