pytest-testinfra icon indicating copy to clipboard operation
pytest-testinfra copied to clipboard

Some commands require further input after sending remote commands.

Open chengxiang1997 opened this issue 1 year ago • 1 comments

Some commands require further input after sending remote commands. What can I do if I'm using TestInfra? For example, when I input mkfs.ext4 /dev/sdb, it prompts the following content:

[root@localhost ~]# mkfs.ext4 /dev/sdb
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n)

If I want to further input y through a Python script, how can I do that?"

chengxiang1997 avatar Oct 17 '24 02:10 chengxiang1997

This is not an issue with this project itself, but with the fact that you are trying to run a command that requires interaction with the end user to confirm next steps.

This is a common situation when you try to run commands remotely (such as pytest-testinfra does) since they use non-interactive shell (as everything is run programmatically).

To solve this, you may need to explore ways to force the command to be executed without asking you for confirmation. E.g. some commands provide the -y option to auto-approve operations.

You may consult the man page of mkfs to see which option suites your needs: https://linux.die.net/man/8/mkfs.ext4 (maybe the -F opt)

narmaku avatar Oct 17 '24 03:10 narmaku