Windows alternative to pexpect

前端 未结 3 444
灰色年华
灰色年华 2021-01-04 22:50

I\'m trying to write a cross-platform tool that runs specific commands, expects certain output for verification, and sends certain output (like username/password) f

3条回答
  •  囚心锁ツ
    2021-01-04 23:56

    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_docker Demo_code.py DOckerfile requirements.txt

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

    vi requirements.txt pexpect==4.8.0

    vi Dockerfile python:latest COPY . . COPY . reqitrements.txt RUN pip3 install -- requirement requirements.txt CMD ["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

提交回复
热议问题