In my shell script I am running a command which is asking me for input.
How can I give the command the input it needs automatically?
For example:
$cat test.sh
ssh-copy-id tester@10.1.2.3
When running test.sh:
-
First, it will ask:
Are you sure you want to continue connecting (yes/no)? -
Then, it will ask me to input the password:
tester@10.1.2.3's password:
Is there a way to input this automatically?
For general command-line automation, Expect is the classic tool. Or try pexpect if you’re more comfortable with Python.
Here’s a similar question that suggests using Expect: Use expect in bash script to provide password to SSH command