pexpect

Automate SSH without using public key authentication or expect(1)

Is there a way to pass a password to ssh automatically. I would like to automatically ssh to a server without using public key authentication or expect scripts, by somehow getting ssh to read the password from stdin or a file. The reason it has to be that way is that I would like to backup my files to a server using rsync/ssh running as...

Pexpect, running ssh-copy-id is hanging when trying to spawn a second process

I'm doing a Python script where I need to spawn several ssh-copy-id processes, and they need for me to type in a password, so i'm using PExpect. I have basically this: child = pexpect.spawn('command') child.expect('password:') child.sendline('the password') and then I want to spawn another process, I don't care about this one anymore...

python, set terminal type in pexpect

I have a script which uses pexpect to start a CLI program. It works a bit like a shell where you get a prompt where you can enter some commands. The problem I have, I think, is that this program uses a coloured prompt. This is what I do import pprint import pexpect 1 a = pexpect.spawn('program') 2 a.expect("prompt>") 3 print "------...

How to spawn multiple python scripts from a python program ?

Hi I want to spawn (fork?) multiple Python scripts from my program (written in Python too) My problem is that I want to dedicate one terminal to each script , because I'll gather their output using pexpect. I've tried using pexpect, os.execlp and os.forkpty but neither of them do as I expect. I want to spawn the child processes and forge...

how to get console output from a remote computer (ssh + python)

Hi All, I have googled "python ssh". There is a wonderful module "pexpect", which can access a remote computer using ssh (with password). After the remote computer is connected, I can execute other commands. However I cannot get the result in python again. p = pexpect.spawn("ssh user@remote_computer") print "connecting..." p.waitnoe...

passing ctrl+z to pexpect

How do I pass a certain key combination to a spawned/child process using the pexpect module? I'm using telnet and have to pass Ctrl+Z to a remote server. Tnx ...

How to set explicitly the terminal size when using pexpect

I have a ncurses app that checks terminal size at startup and exits immediately if it doesn't fit. In Linux, the default size is 80x24, this app requires at least 25. The fix is easy, I'm just resizing the terminal emulation window (in X) before running the ncurses app. I would like to automate the ncurses app with pexpect, but I'm get...

Problem with pexpect and 'chained' function calls.

The class below is designed to manipulate a cisco-like device interface, for the purpose of executing commands and updating configuration elements. As is currently stands, I can instantiate the class, make a call to the ssh_to_aos_expsh function and get back valid output (e.g. get the config when the command is 'show running-config'). ...

pexpect parse router output

I've got a couple of pexpect lines to log onto a cisco router, and issue the show arp command. I then exit the router, having stored the data into the variable myARP (myARP=child.before) When I then try and loop over the object (for lines in myARP: print(lines), the info is displayed 1 character per line l i k e t h i s Apologies...

writing pexpect like program in c++ on Linux

Is there any way of writing pexpect like small program which can launch a process and pass the password to that process? I don't want to install and use pexpect python library but want to know the logic behind it so that using linux system apis I can build something similar. ...

Grabbing the output of MAPLE via Python

How would I use the subprocess module in Python to start a command line instance of MAPLE to feed and return output to the main code? For example I'd like: X = '1+1;' print MAPLE(X) To return the value of "2". The best I've seen is a SAGE wrapper around the MAPLE commands, but I'd like to not install and use the overhead of SAGE for ...

Python Pexpect getting all output from child

I am trying to get all output from child process in real time. I use spawn for creating child process but I am confused what I should send for pattern parameter in expect function. Actually I don't understand why it's not an optional parameter. I don't know if I should use send(), child doesn't need input. I'm just trying to write outpu...

Verify a file exists over ssh

Hello, I am trying to test if a file exists over SSH using pexpect. I have got most of the code working but I need to catch the value so I can assert whether the file exists. The code I have done is below: def VersionID(): ssh_newkey = 'Are you sure you want to continue connecting' # my ssh command line p=pexpe...

simple twisted server (twistd .tap)with a pexpect instance error

Hi all, I have been creating an async server socket that sends and recives xml using twisted. The application works great! but because my main objective was to embed it in an init.d script and make it run in the background i decided to transform it in a "twisted application" in order to run it using twistd # from twisted.internet impor...

Python: win32console import problem

I want to run wexpect (the windows port of pexpect) on my Windows 7 64-bit machine. I am getting the following error: C:\Program Files (x86)\wexpect\build\lib>wexpect.py Traceback (most recent call last): File "C:\Program Files (x86)\wexpect\build\lib\wexpect.py", line 97, in raise ImportError(str(e) + "This package was intended f...

How to install wexpect?

Hello, I'm running 32-bit Windows XP and trying to have Matlab communicate with Cgate, a command line program. I'd like to make this happen using wexpect, which is a port of Python's module pexpect to Windows. I'm having trouble installing or importing wexpect though. I've put wexpect in the folder Lib, along with all other modules. ...

Could not run pexect with cygwin

Getting following errors while executing pexpect example file on cygwin prompt. Can anyone help? > Administrator@INDSQA2253 /cygdrive/c/Python26/Tools/pexpect-2.1/examples $ python ssh_session.py Traceback (most recent call last): File "ssh_session.py", line 7, in from pexpect import * File "c:\Python26\lib\site-packages\pexpe...

To stop returning through SSH using Pexpect

Hello, I am trying to use pexpect to ssh into a computer but I do not want to return back to the original computer. The code I have is: #!/usr/bin/python2.6 import pexpect, os def ssh(): # Logs into computer through SSH ssh_newkey = 'Are you sure you want to continue connecting' # my ssh command line p=pexpect.spawn(...

Is there autoexpect for pexpect?

I would like to generate Python Expect (pexpect) code automatically, does something like autoexpect exist for pexpect? ...

python,running command line servers - they're not listening properly

hello all Im attempting to start a server app (in erlang, opens ports and listens for http requests) via the command line using pexpect (or even directly using subprocess.Popen()). the app starts fine, logs (via pexpect) to the screen fine, I can interact with it as well via command line... the issue is that the servers wont listen fo...