Connectport X2

Right now when I am running my python program on Connectport X2 and the output is stored at X-2. I want to store the output as well as at the computer to which it is telneting.

Is there some way to do it?

Hi hirdeep,

If the output of the application is stored on the file system of the X-2, you may want to consider using an authenticated HTTP GET to retrieve it from the PC.

I’m not sure what you mean by to which it is telneting. Do you mean the Connectport X2 is using a telnet client to login to a remote destination? Or is a PC using the telnet client to login to the X2 and launching the application?

Actually, I am new to Python and entire networking. I don’t know what is authenticated HTTP GET is and how to use it ?

As far second question is concerned:
PC is using the telnet client to login to the X2 and launching the application?

I am curious how X-2 can use telnet client to login to a remote destination on it’s own?

Python can make the X2 do many things.

Why don’t you step back and explain what you really want to do - what is your goal? What creates your data, and where do you want that data to be used?

Right now, my PC is telneting with X-2 and is running Python program on X-2. The results of that program are being stored on X-2. I want that data to be stored on my PC too.

About the second question, till now with what I have worked I was only able to telnet from PC to X-2 and not the other way around.

I am just curious that is it possible that when X-2 gets particular reading from any of its end-device and based on that reading it establishes connection to remote device?

The HTTP GET may be the best solution for this, depending on what type of access you have to the X2. This would not necessarily have to be programmed in python even, as the built in web server to the X2 services the GET requests already.

When you get closer to a production environment, you may want to consider launching the python scripts on the X2 through the autostart feature on the device. To do this, the ‘set python’ command is used. A typical usage is ‘set python range=1 state=on command=“myscript.py arg1 arg2 arg3”’

For the HTTP GET it is really up to you on how to do it. I wrote a quick example using the standard python library which retrieves a file called ‘info.log’ from the device using a HTTP GET request:

import httplib
conn = httplib.HTTPConnection(‘10.9.109.34’)
conn.request(‘GET’, ‘/FS/WEB/python/info.log’)
resp = conn.getresponse()
if resp.reason == ‘OK’:
data = resp.read()
print data
else:
raise RuntimeError(“Failed to get resource, reason: %s” %resp.reason)

Warning though, because you are using HTTP and not HTTPS, the GET request and response are basically in clear text. If you are concerned about other people reading the data, then you should build a SSL tunnel on the device, as the X2 does not support HTTPS.