Example of marrying Python's paramiko and pexpect? - pexpect

The documentation for the pxssh portion of pexpect suggests using paramiko but then gives no examples. So does this mean "use paramiko and ignore pexpect completely" or is there a way to create an ssh session using paramiko and then drive it using pexpect?
If the latter, anyone got a very simple example of how to do this?

Related

Getting Error: pexpect not installed, try: pip install pexpect

Configuring Rundeck remote windows node using py-winrm. Successfully configured using Basic Auth, then trying to configure to use Kerberos I started getting an error meeting the requirements for Py-Winrm.
Rundeck 3.3.11 with py-winrm on Windows Server 2016 Server. Getting an error connecting to remote host running a Command job.
Error: pexpect not installed, try: pip install pexpect
Python3.9.6
verified pexpect 4.8.0 installed using pip list
I've tried;
uninstalled/reinstalled pexpect and Python and restarted Windows after Python reinstall and Rundeck Service after each change.
Any help would be greatly appreciated.
Thank you
Go to Project Settings > Edit Configuration and click on the "Default Node Executor" tab, (make sure that you're using "WinRM Node Executor Python" as default node executor), on the "Python Interpreter" textbox put the python3 binary full path (the python3 path that you're used to installing the pexpect module). Same for the "Default file copier" tab.

Am I required to use Amazon Linux on AWS lambda?

I am trying to zip python 2.7 code with pandas and cassandra libraries on my local windows 7 computer. From the anaconda prompt I did pip install -t 'folder location' for both pandas and cassandra and I zipped the contents - not the folder. I am getting the error Unable to import module 'lambda_function': Missing required dependencies ['numpy']. However, pandas included numpy as a dependency and it is in the zip file. zip file contents
I researched this isssue, and found Pandas & AWS Lambda the marked answer says: All static packages have to be compiled on an EC2 Amazon Linux instance.
This article that was referenced in another question Problems using MySQL with AWS Lambda in Python says to use EC2 Amazon linux and virtualenv: http://www.perrygeo.com/running-python-with-compiled-code-on-aws-lambda.html
Does this mean I am having problems because I am using my local windows 7 computer, is it required to use EC2 Amazon linux?
I believe the answer to my question is Yes, you do have to use EC2 Amazon Linux. I found this post on the AWS forum regarding the Cassandra-Driver library: https://forums.aws.amazon.com/thread.jspa?threadID=247496
I was a little unsure about how to do this but I found a great tutorial from AWS:
https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-deployment-pkg.html
I followed the instructions and created a virtualenv and downloaded everything - seems to be working. I got past that error but now it is unable to download from S3, I will create a new thread for that.

Shade (python) module used by ansible needed but installed from yum not pip.

hi,
i am learning Openstack Newton and i'm building a lab. I have a pc which serves as controller and a Dell PowerEdge 2950 which will serve as compute node. I have another computer which will be the Ansible node. I made my first ansible playbook and tried to run it on the controller but i get an error (i need shade module installed on controlled).
Here is the problem. If i install shade using pip it messes with my openstack controller and the horizon dashboard is not accesible anymore, i get http error 500.
Is there a shade module in yum and how is it called?
thank you.
It's always better to use virtualenv to separate python contexts.
So create a virtualenv, activate it, install ansible and any necessary library (without messing up with the system python libraries) and launch ansible.
If you don't want to use ansible in a virtualenv, you can create one just for the task execution by setting ansible_python_interpreter for localhost (take a look at this answer).

Python and OpenSSH

I feel like there is something fundamental I'm missing here, and because of that googling the error has been very difficult.
I've set up an SSH connection to my home computer using the instructions I found here:
https://winscp.net/eng/docs/guide_windows_openssh_server
I'm able to access ipython interactively by entering ipython but the prompt is not behaving at all like I expect. Please see the following interaction:
The session isn't immediately responsive and seems to be running the commands in some type of batch mode, and still not all of them. I don't receive any output until I exit the program. Running python and not ipython behaves similarly. I'm hoping to have a somewhat more standard interactive python experience, and have no idea how to go about debugging this.
Information on my system:
OS - Windows 10, both machines
SSH - OpenSSH set up through link above
Python - 2.7.11, Anaconda install 2.5.0
Remote access application - Putty
Thanks for any help-

Check if a python script is running on remote machine

I am running a python script on say machine A. Is there any way to know if the python script is running or not from another machine B from command line? I tried getting the process list from the task manager. But it does not show any information regarding this script though it is running( it only showed cmd through which the script is executing ).
This will be a three step process. Step 1 is only required because you are Windows. If you're Mac or Linux, they already come with Step 1 completed for you. Otherwise, this is completely cross-platform capable.
1) You need to remotely connect from Machine A to Machine B. One extremely popular way of doing this is SSH, which can be installed on Machine A and Machine B. The recommended way to do this is with FreeSSHd, which has been very well documented here: https://serverfault.com/questions/8411/what-is-a-good-ssh-server-to-use-on-windows
2) Install the paramiko SSH library for Python. This will allow you to connect to another machine, and execute any arbitrary command line command. On windows, you just need to install the binaries for paramiko and pycrypto/openssl. This also is well documented on SO here: installing paramiko on Windows
3) Decide how you want to harvest the process list. There are several ways which are well documented here: https://stackoverflow.com/questions/53489/how-do-you-list-all-processes-on-the-command-line-in-windows

Resources