Windows alternative to pexpect Windows alternative to pexpect windows windows

Windows alternative to pexpect


You can use wexpect ("Windows alternative of pexpect", Python Software Foundation). It has the same functions, and it works on Windows .


Instead of using pexpect.spawn you can use pexpect.popen_spawn.PopenSpawn for windows.

child = pexpect.popen_spawn.PopenSpawn('cmd', timeout=1)child.send('ipconfig')child.expect('Wireless', timeout=None)


Better solution is to move DOCKER.It will solve the entire Linux <-> Windows Dependecies in all kind of process.Very simple steps are there to convert a any .py code into a Docker-image.This will be the Futreistic an doptimised solution to use pexpect in windows.

The Example for Encapsulating Python in container:In Linux :Step 1: https://docs.docker.com/engine/install/centos/After the installation ,one can get docker as a sytem command in linux.Step 2 : Create a directory , and copy the python in that directory and create a ne file called "Dockerfile" and also have the requirements.txt

root@host_name~#cd Demo_dockerDemo_code.py DOckerfile requirements.txt

vi Demo_code.py
import pexpect
a=2+2
print(a)

vi requirements.txtpexpect==4.8.0

vi Dockerfilepython:latestCOPY . .COPY . reqitrements.txtRUN pip3 install --requirement requirements.txtCMD ["python","Demo.py"]

Step 3: Use Docker build command to build and run and you can upload this to "dockerHUB" and then pull to any where in the world.

After you pushed the image to Docker-Hub , in windows one need to download "Docker Desktop Appliaction" and the use "Docker pull command to pull the repo which you pushed to Docker-hub