In article <[EMAIL PROTECTED]>, Carl J. Van Arsdall <[EMAIL PROTECTED]> wrote: >Well, although you spawn seperate telnet processes there is still only >one thread of control in your pythons script. If you need to do two >things simultaneously you'll need to setup a parallel control >mechanism. For example you could use python threads, each thread spawns >a separate telnet and controls it accordingly. Similarly, you could >fork off other python scripts that control each telnet session. > >Alright, so that's for controlling two telnets at once. I think you'll >have another problem, and that's controlling each telnet session >manually. To do this I think you'll need to setup an interface that >provides the two consoles you are after. I'm not exactly sure the best >way to do that. One thought I have is if you used one of the various >GUI toolkits you could have your app open a window that is seperated >into two consoles. Each thread could be bound to one of these consoles >and you could switch between the two by clicking on one side versus the >other. Although if you want to do it all in a shell, or have your >program open multiple shells I'm not sure how to do that, you might >check google. I suppose if you were doing things from a single shell >and wanted to do thing similar to the GUI toolkit I described earlier, >you could try something like ncurses. > >I guess I have one final idea, you could use a single shell, buffer >output from each telnet session and have your main control loop give you >the ability to switch back and forth between the two sessions. > >Anyhow, hope those ideas help you out a little. > >vmalhotra wrote: >> Hi >> >> I am new in python scripting. I want to open a Multiple telnet session >> through once script. In other way i can tell i want to open two linux >> consoles through one script. >> >> I wrote one script, but the issue is I am not able to open multiple >> consoles. The Scripts which i wrote is as follows: >> >> import pexpect >> session = pexpect.spawn("telnet localhost 2601\n") >> session.expect("Password: ") >> session.send("XYZ\n\n") >> session.expect("Router1> ") >> session1 = pexpect.spawn("telnet localhost 2604\n") >> session1.expect("Password: ") >> session1.send("ABCD\n\n") >> session1.expect("ospfd> ") >> #session1.interact() >> session1.interact() >> >> output : >> ospf> >> >> But in this case, i want in one console router one can open and on >> other console ospf should open. But this i want to do is through one >> script only. . . . While pexpect makes these matters feasible, the Tcl-based Expect <URL: http://wiki.tcl.tk/expect > has had years more practice dealing with concurrency and its consequences. If this problem were mine, I'd start with Expect. -- http://mail.python.org/mailman/listinfo/python-list