views:

123

answers:

2

I am able to establish the initial telnet session. But from this session I need to create a second. Basically I can not telnet directly to the device I need to access. Interactively this is not an issue but I am attempting to setup an automated test using python.

Does anyone know who to accomplish this?

A: 

After establishing the first connection, just write the same telnet command you use manually to that connection.

unbeli
I attempted to do this using tn.write("telnet 192.168.16.50\n") and then tn.read_until("->",5)If I don't add the second (timeout) parameter, 5, it never seems to find the "->" prompt.
Jay B
Update: This method is in fact working, sort of...I suppose its a bit of a hack. The tn.read_until is failing I believe because it is attempting to read from the orignal telnet session or B as Uri dubbed it. So the prompt it was "reading" for was never found.I discovered I was missing some required quotes to load one of my scripts on device C. After adding the appropriate quotes, I am now able to control device C.: )Thanks
Jay B
A: 

If you log in from A to B to C, do you need the console input from A to go to C ?

If not, it is fairly straightforward, as you can execute commands on the second server to connect to the third.

I do something like that using SSH, where I have paramiko and scripts installed on both A and B. A logs in to B and executes a command to start a python script on B which then connects to C and does whatever.

Uri
Yes, I need console input from A to go to C.I like the idea of running a second script on B, however in this instance i am limited by what I am able (allowed) to install/run on B.
Jay B
Do you need A to read stuff from C, or just to blind write to C ?
Uri