Questions tagged [pxssh]

This tag refers to the pxssh python library - used for creating and using SSH via a python script.

This tag refers to the pxssh python library - used for creating and using SSH via a python script.

49 questions
4
votes
1 answer

Got stuck with pxssh. It doesn't login again after the first successful login?

I'm working on simple ssh login using pxssh. Following T.J. Connor scripts from Cookbook. I was able to successfully get into the remote machine using pxssh and pass commands when trying from the python interpreter. Below is the view. >>> from…
harveyD
  • 579
  • 5
  • 17
3
votes
1 answer

Disable remote prompt using pxssh

I am using pxssh to log in and issue some commands on a remote server. My code looks like: def login(self): try: self.connection = pxssh.pxssh() self.password = getpass.getpass('Password: ') self.connection.login(self.host,…
Albert
  • 191
  • 1
  • 3
  • 23
2
votes
1 answer

Pexpect: Could not set shell prompt

I have referred a python script from https://pexpect.readthedocs.io/en/stable/api/pxssh.html in order to perform a ssh password based login. Code is as follows: from pexpect import pxssh import getpass try: s = pxssh.pxssh() hostname =…
rakesh kotian
  • 232
  • 1
  • 5
  • 30
2
votes
1 answer

Regexp to match prompt in pxssh

I am using pxssh in Python3.6 to play with SSH by doing a script. Everything works fine but I just have one little issue. The prompt on the machine I'm logging on SSH change according to some commands I'm sending (not all!) Here is the code of my…
Difender
  • 495
  • 2
  • 5
  • 18
2
votes
1 answer

AttributeError: 'NoneType' object has no attribute 'sendline' yet module contains the attribute having tested it another way?

After importing the relevant libraries and creating a connect function using the pxssh library, I have created my main function to accept the arguments of 'host, 'user' and the filename that I give. The program successfully reads the file and…
Dac121
  • 41
  • 4
2
votes
1 answer

How do I install pxssh? Module not found

I get the error message module not found for pxssh. I am running ubuntu 16.04 with Python 2.7.12 with expect 4.0.1-1. import pxssh ImportError: No module named pxssh Is pxssh included in pexpect
Randolph Hill
  • 81
  • 1
  • 1
  • 5
1
vote
1 answer

python | pexpect | ssh | no indication is received when the dest host is not reachable

I'm using pexpect to connect with ssh to a distance host. when the user or password are incorrect, I get an error but when the dest host is not reachable (for example when I entered an invalid ip or if the host is down) I don't get any…
Tal Levi
  • 363
  • 1
  • 6
  • 22
1
vote
0 answers

PXSSH Connection fails sometimes randomly after upgrading to Python3

I am trying to create a ssh session using pexpect.pxssh as follows: from pexpect import pxssh connection = pxssh.pxssh() connection.login('localhost', username, password, port=port, check_local_ip=False) """ Fails with the following…
Satya Prakash
  • 35
  • 1
  • 6
1
vote
0 answers

Can i use pxssh and pexpect together?

I'm using a pxssh to make connection to remote server and do a some commands, after that i need to return a stdout and push it to my html webpage. This construction is not work because it's give all output (command and output) in string (without any…
1
vote
2 answers

How to escape a Linux command which has all characters like single quote, double quote(',",`) in python?

I have the following Linux command which gives metrics like CPU%, RAM%, and Hard disk percentage. echo "CPU `LC_ALL=C top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}'`% RAM `free -m | awk '/Mem:/ {…
rakesh kotian
  • 232
  • 1
  • 5
  • 30
1
vote
0 answers

PXSSH truncates command sent to remote server

I have a python application that sends a wide variety of unix commands using pxssh to a remote server using the versions below. Version info: Python - 3.6.5 pexpect - 4.2.1 On one particular server one of our commands failed to execute because the…
Craig Souder
  • 68
  • 1
  • 4
1
vote
1 answer

The pexpect pxssh do not create my requirement directory

I use the pexpect module to login a ssh server and then mkdir a directory: from pexpect import pxssh s = pxssh.pxssh() s.login(server='43.24.24.29', username='root', password='my_password') s.send('mkdir aaa') s.logout() it works, but I find,…
user7693832
  • 6,119
  • 19
  • 63
  • 114
1
vote
2 answers

Can the Ansible raw ssh module be used like "expect"?

In other words, can the ansible "expect" module be used over a raw SSH connection? I'm trying automate some simple embedded devices that do not have a full Python or even shell. The ansible raw module works fine for simple commands, but I'd like to…
Wafflecode
  • 45
  • 9
1
vote
1 answer

Python pxssh sendline string splitting and sending two lines

This is my first question here, and I'm far from professional coder, but I have been researching and didn't found any similar problem to this... I stated in the title which is pxssh realted, but in fact applies to many otehr cases seems. The problem…
lopalcar
  • 33
  • 1
  • 9
1
vote
1 answer

Use a here-document with pxssh (pexpect)

In my python script I need to execute a command over SSH that also takes a heredoc as an argument. The command calls an interactive script that can be also called as follows: dbscontrol << EOI HELP QUIT EOI I also found this Q&A that describes how…
Bostone
  • 36,858
  • 39
  • 167
  • 227
1
2 3 4