Telnet client control panel python - python

I am working on Jasmin SMS gateway and I want to use its CLI module using my python script. It serves this module as telnet. I am not sure ho to send and receive commands from telnet. I have tried telnetlib but I do not know how to use it properly. Jamsin SMS Gateway can be found here:
https://jasmin.readthedocs.io/en/latest/management/jcli/index.html#architecture

I found pexpect library that works great with telnet and ssh clients. I can perform all the tasks of Jamsin's CLI module using my scripts.
There is also a web interface available written in Django and work perfectly with jasmin using pexpect. Its called JasminWebPanel.

Related

Using Python for Cisco network admin

I started learning Python and I am trying to find a usage in networking and writing scripts.
My question is more of a newbie in dev. I'm learning how to access SSH with Paramiko, then collect info from a device, manipulate data, and push some commands.
Is there any ideas or ways of what can be done and/or automated using Python?
U can Log to the cisco router using paramiko and issue a show log in loop, if in show log command any BGP flap will occure then script will sent you a mail using win32com module or smtplib module. If any webbrowser application ( like trouble ticket system) is related to your daily job with a a cisco devices you can also use a selenium module to automatically manipulate a webrowser.

Defining a Proxy used by the Azure IoT Hub Client (Python)

I am using the Azure IoT Hub Client SDK for Python. I am using a slightly modified version of the sample script from the github repo to upload files to the IoT Hub. Everything works fine as long as I do not have to use a proxy for outgoing connections.
I tried to understand how to configurate a proxy for this, but I did not find anything for the Python SDK. I searched also in the other SDKs and found some ProxySettings in the iothub_client_options.h of the C SDK. But I do not know how to set these settings in the python client (in case the settings are actually working).
I also found an issue that the connection over websockets needs some special format of the Linux environment variables. But I do not use websockets.
I tried to run my script both in Windows and Linux environments where the proxy system settings are correctly configured (Win: Internet settings, Linux: environment variables).
Is there any documentation on this topic? Does anybody how to configure a proxy either on windows or on linux?
Per my experience, I think you can run the python script using Azure IoTHub Client SDK without any proxy settings to communicate with Azure IoT Hub if the OS configured correctly the proxy.
However, there are some notes which need to be focused by using different protocol (such as HTTP, Socks, etc) configured in proxy server, as below.
Normally, the proxy server was configured for working on HTTP protocol which only allow the HTTP communication. So if using IoTHub Client within HTTP mode, the script will works fine, but not works within AMQP/MQTT mode.
If the proxy server was configured for working on Socks protocol, such as Socks4/Socks5, the script within any mode will works fine, because the Socks protocol just transmit datagram, not check the protocol type.
So please check which protocols be supported in your proxy server, then to use HTTP mode or configure Socks protocol for proxy to make the script works.

communicating with Python socket server (Chrome extension)

i am trying to write a simple extension in chrome which sends data to a TCP socket server in python.
Unfortunately, extensions cannot use sockets library in chrome.
is there any simple way to communicate with a TCP socket server in python?
Alternatively, is there any way to communicate with python at all?
I think Native Messaging is what you want.
You can find a example code snippet in the Example section of this page.
It uses native messaging to communicate with a Python script.

Using Paramiko for server

I was wondering, I want to create a SSH server and a client with custom commands.
I thought of using Twisted for it, but I did not go well with the docs.
I decided to use Paramiko, but I wonder, is there any way to create a Paramiko server? Or only client?
Another question, let's say you can only create a client, can I create the client in Paramiko and the server using the socket module and connect to it? Is this possible?
If so, any advice?
Thanks in advance
Yes, Paramiko can be used both as an SSH client and server; see paramiko.Transport.start_server to get started.
If you go back and revisit Twisted, twisted.conch also implements SSH.

Embedding a remote Python shell in an application

You can embed the IPython shell inside of your application so that it launches the shell in the foreground. Is there a way to embed a telnet server in a python app so that you can telnet to a certain port and launch a remote IPython shell?
Any tips for redirecting the input/output streams for IPython or how to hook it up to a telnet server library or recommendations for other libraries that could be used to implement this are much appreciated.
Python includes a telnet client, but not a telnet server. You can implement a telnet server using Twisted. Here's an example. As for hooking these things together, that's up to you.
Use Twisted Manhole. Docs are a bit lacking, but it's easy enough to set up a telnet-based remote server and it comes with a GTK-based GUI.
Main Twisted site
twisted.manhole API docs
I think you should base your server class on the SocketServer class from the standard library. You'll need to write a RequestHandler to read and echo input but a lot of the heavy lifting is already done for you.
You can use the ThreadingMixIn to make the server multi-threaded very easily.
Try to use xmlrpc namespace

Categories

Resources