473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Re: SSH utility

for similar tasks, I use pexpect http://pypi.python.org/pypi/pexpect.

spawning bash process and simulate an interactive session. Here sending ls command, retrieving results and exiting. In the spawned process ssh or any other command, is just another command.

------------actual session--------------------------
$ python
Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>import pexpect
c = pexpect.spawn('/bin/bash')
c.expect([pexpect.TIMEOUT, pexpect.EOF, '\$ '])
2
>>c.before, c.after
('\x1b[?1034hmadared@NJWARHQD0IT696A:~\r\n', '$ ')
>>c.sendline('ls')
3
>>c.expect([pexpect.TIMEOUT, pexpect.EOF, '\$ '])
2
>>c.before, c.after
('ls\r\x.txt xx.txt xy.txt y.txt\r\nmadared@NJWARHQD0IT696A:~\r\n', '$ ')
>>c.sendline('exit')
5
>>c.expect([pexpect.TIMEOUT, pexpect.EOF, '\$ '])
1
>>c.before, c.after
('exit\r\nexit\r\n', <class 'pexpect.EOF'>)
>>exit()
madared@NJWARHQD0IT696A:~
$
---------------------------------------------------------------

hope that helps.

regards.
Edwin
-----Original Message-----
From: py************************************************ **@python.org
[mailto:py***************************************** *********@python.org]
On Behalf Of James Brady
Sent: Monday, August 11, 2008 12:26 AM
To: py*********@python.org
Subject: SSH utility
Hi all,
I'm looking for a python library that lets me execute shell commands
on remote machines.

I've tried a few SSH utilities so far: paramiko, PySSH and pssh;
unfortunately all been unreliable, and repeated questions on their
respective mailing lists haven't been answered...

It seems like the sort of commodity task that there should be a pretty
robust library for. Are there any suggestions for alternative
libraries or approaches?

Thanks!
James
--
http://mail.python.org/mailman/listinfo/python-list

The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure. If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof. Thank you.
Aug 11 '08 #1
1 1789
On Aug 11, 5:17*am, Edwin.Mad...@VerizonWireless.com wrote:
for similar tasks, I use pexpecthttp://pypi.python.org/pypi/pexpect.

spawning bash process and simulate an interactive session. Here sending ls command, retrieving results and exiting. In the spawned process ssh or any other command, is just another command.

------------actual session--------------------------
$ python
Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.>>>import pexpect
>c = pexpect.spawn('/bin/bash')
c.expect([pexpect.TIMEOUT, pexpect.EOF, '\$ '])
2
>c.before, c.after

('\x1b[?1034hmadared@NJWARHQD0IT696A:~\r\n', '$ ')>>c.sendline('ls')
3
>c.expect([pexpect.TIMEOUT, pexpect.EOF, '\$ '])
2
>c.before, c.after

('ls\r\x.txt *xx.txt *xy.txt *y.txt\r\nmadared@NJWARHQD0IT696A:~\r\n', '$ ')>>c.sendline('exit')
5
>c.expect([pexpect.TIMEOUT, pexpect.EOF, '\$ '])
1
>c.before, c.after

('exit\r\nexit\r\n', <class 'pexpect.EOF'>)>>exit()

madared@NJWARHQD0IT696A:~
$
---------------------------------------------------------------

hope that helps.

regards.
Edwin

-----Original Message-----
From: python-list-bounces+edwin.madari=verizonwireless....@python.or g

[mailto:python-list-bounces+edwin.madari=verizonwireless....@python.or g]
On Behalf Of James Brady
Sent: Monday, August 11, 2008 12:26 AM
To: python-l...@python.org
Subject: SSH utility

Hi all,
I'm looking for a python library that lets me execute shell commands
on remote machines.

I've tried a few SSH utilities so far: paramiko, PySSH and pssh;
unfortunately all been unreliable, and repeated questions on their
respective mailing lists haven't been answered...

It seems like the sort of commodity task that there should be a pretty
robust library for. Are there any suggestions for alternative
libraries or approaches?

Thanks!
James
--http://mail.python.org/mailman/listinfo/python-list

The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure. *If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof. *Thank you.
I second pexpect and the nice little module that comes with it
ssh_session.py.

Been using it for ages now!

~Sean
Aug 11 '08 #2

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

Similar topics

0
by: Zane Thomas [.NET/C# MVP] | last post by:
If, like me, your connection is being swamped downloading copies of the Swen Worm and bounce messages, you might find the utility I wrote today useful. Source for the utility is distributed with...
2
by: stefanPL | last post by:
Hello, I have SQL Server 2000 Developer Edition. Where is SQL Server Network Utility? In Start menu SQL server group I have only Client Network Utility :| Is it a command line tool or sth? How...
2
by: Mike Metzger | last post by:
I've been running an Access2000 database for a couple years on a Win2k machine fine. We tried to copy the database over to another machine that already had Access2000 installed. When we tried to...
5
by: Diffident | last post by:
Hello All, I have written a webform which is by default derived from "Page" class. I have coded another utility class with few methods and an object of this class is instantiated from the webfom...
5
by: Jeff | last post by:
We are using .Net and the wsdl Utility to generate proxies to consume web services built using the BEA toolset. The data architects on the BEA side create XML schemas with various entities in...
1
by: huyuhui | last post by:
The following is a question of LOAD utility. Question: How does the DB2 enforce table check constraints for data added to table with the LOAD utility? A. With the BUILD phase of LOAD B. With the...
27
by: Neil | last post by:
Anyone have a recommendation for a good inexpensive or free utility for developing table schemas.
0
by: TC | last post by:
Years ago, I found a utility which estimated the size of all objects in an .mdb file and presented the results in a nicely-formatted grid. I no longer have that utility, and I can't find it...
5
by: Kurt Jakobsen | last post by:
Hello, I have a utility class that do some db queries that are used by independent pages. From one of the utility functions I would like to return variables back to the aspx page. In old C this...
0
by: hsheboul | last post by:
Thanks to Markus for pointing me to all the Apache stuff http://bytes.com/topic/html-css/answers/876342-automating-web-site-template My Web site is hosted on a shared Linux hosting, that runs the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.