473,698 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Telnet sessions through one script

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("X YZ\n\n")
session.expect( "Router1")
session1 = pexpect.spawn(" telnet localhost 2604\n")
session1.expect ("Password: ")
session1.send(" ABCD\n\n")
session1.expect ("ospfd")
#session1.inter act()
session1.intera ct()

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.

Regds
Vik

Jul 31 '06 #1
2 7710
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("X YZ\n\n")
session.expect( "Router1")
session1 = pexpect.spawn(" telnet localhost 2604\n")
session1.expect ("Password: ")
session1.send(" ABCD\n\n")
session1.expect ("ospfd")
#session1.inter act()
session1.intera ct()

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.

Regds
Vik


--

Carl J. Van Arsdall
cv*********@mvi sta.com
Build and Release
MontaVista Software

Jul 31 '06 #2
In article <ma************ *************** ************@py thon.org>,
Carl J. Van Arsdall <cv*********@mv ista.comwrote:
>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.expec t("Password: ")
session1.send( "ABCD\n\n")
session1.expec t("ospfd")
#session1.inte ract()
session1.inter act()

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.
Aug 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
31195
by: john | last post by:
How do u guys handle multiple sessions?? i.e, opening different browser windows by running iexplore.exe or clicking IE icons and opening the application. My sessions are mixing up. what i mean is suppose i log in my site using username "test". At this time I set $_SESSION="test". And I use $_SESSION inside my application to print the username. Now if I open another browser & log in with "another test" the session
4
6859
by: Pekka Niiranen | last post by:
Hi, I have a multiuser script, that I would like to convert to Python. The users open simultaneous telnet -sessions from win2000 to an unix machine and possibly edit unicode textfiles. Currently users use vi and more, but I would like to add unicode support to the script. I would not like to force them to open X-sessions in order to show Multilanguage characters. Should I create python shell or is there any other way ?
6
6463
by: Richard Bird CCNP, CCDP, MCSE, etc. | last post by:
I need some help adding multithreading to an existing python script. The script was developed to telnet and make changes on a list of cisco routers. I figure that by adding multithreading, I'd be able to telnet to several routers concurrently and speed up the process of making changes. Is this feasible using python with its standard telnet lib?
1
4047
by: Tony Pryor | last post by:
Hello, Anyone know if running two client telnet sessions at the same time should be an inherent problem? They don't seem to want to share a port or are they trying to use the same console for interaction with the connected servers? -Tony Hello from parent loop 1 ipaddress1
1
2360
by: Michael | last post by:
Dear all, Given the following challenge: 1. The application is an exe on a W2K server 2. User logs via telnet to the server 3. After checking the user account and password, a bat file runs cmd.exe that starts the app. 4. The app starts looking for another instance of itself and if it was found it will kill the instance (but not the telnet session that originally started the instance as described in 1. to 3.)
1
1914
by: Siva Palaninathan | last post by:
Hi, I am trying to automate telnet sessions to retrive information from a linux box. The box is not running a full-featured version of linux, embedded linux, has very limited sources, memory, computing power and etc. What I am trying to do is connect to the box, run some commands, save the telnet session in a file. This has to be happening in a timely-fashion without user interaction. What all I'm looking for is a small application or...
18
3389
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site relies on subscrption fees. Sessions ID's are matched between the browser and the server. So a users can login with same username and password and those sessions are tracked individually. Some suggest create table fields with the session ID...
4
2955
by: Patricia Mindanao | last post by:
I want to call cgi perl scripts on my web hosters server from my HTML web pages (on the the web hosters server too). It occurs sometimes (especially during development phase) that these cgi-perl scripts didn't work like intended. They crash because e.g. - syntax errors - wrong or changing pathes - unexpected user input - ...
2
2990
by: thamayanthi | last post by:
Hi, The below code is used to connect to the remote machine using Telnet module in perl. use Net::Telnet; use Net::Ping; $telnet = new Net::Telnet (Timeout=>10,Errmode=>'die'); open (FILE,"C:/start.txt") or die ("Unable to open start.txt"); while(<FILE>)
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9027
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.