Skip to Main Content
Python Network Programming
book

Python Network Programming

by Abhishek Ratan, Eric Chou, Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker
January 2019
Beginner to intermediate content levelBeginner to intermediate
776 pages
19h 58m
English
Packt Publishing
Content preview from Python Network Programming

How to do it...

We can use the paramiko module to create a remote session to a Unix machine. Then, from this session, we can read the remote machine's /proc/cpuinfo file to extract the CPU information.

Listing 6.3 gives the code for printing a remote machine's CPU information, as follows:

#!/usr/bin/env python # Python Network Programming Cookbook, Second Edition -- Chapter - 6 # This program is optimized for Python 3.5.2. # It may run on any other version with/without modifications. # To make it run on Python 2.7.x, needs some changes due to API differences. # Follow the comments inline to make the program work with Python 2. import argparse import getpass import paramiko RECV_BYTES = 4096 COMMAND = 'cat /proc/cpuinfo' def print_remote_cpu_info(hostname, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Network Programming for Network Engineers (Python 3)

Python Network Programming for Network Engineers (Python 3)

David Bombal

Publisher Resources

ISBN: 9781788835466Supplemental Content