From Fedora Project Wiki
Description
This test case ensures that the expect utility can automate interactive command-line programs in Fedora.
Setup
- Ensure the
expecttool is installed. If not, install it with the command:sudo dnf install expect
How to test
- Create a sample
expectscript namedtest_expect.expwith 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
passwdcommand, 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.
