From Fedora Project Wiki
(Created page with "{{QA/Test_Case |description=This test case ensures that the `expect` utility can automate interactive command-line programs in Fedora. |setup= # Ensure the `expect` tool is installed. If not, install it with the command: `sudo dnf install expect` |actions= # Create a sample `expect` script named `test_expect.exp` with the following content: '' #!/usr/bin/expect -f spawn /usr/bin/passwd expect "Changing password for user" send "newpassword\r" expect "New pa...") |
(No difference)
|
Latest revision as of 13:21, 21 August 2023
Description
This test case ensures that the expect
utility can automate interactive command-line programs in Fedora.
Setup
- Ensure the
expect
tool is installed. If not, install it with the command:sudo dnf install expect
How to test
- Create a sample
expect
script namedtest_expect.exp
with the following content:
#!/usr/bin/expect -f spawn /usr/bin/passwd expect "Changing password for user" send "newpassword\r" expect "New password:" send "newpassword\r" expect "Retype new password:" send "newpassword\r" expect eof
(Note: This script attempts to change the current user's password to "newpassword", make sure to change it back after the test or modify the script as needed.)
- Make the script executable:
chmod +x test_expect.exp
- Execute the script:
./test_expect.exp
Expected Results
- The script should interact with the
passwd
command, entering the new password when prompted without any user intervention.
Optional
Explore other interactive command-line programs and try to automate their interaction using expect
.