Reputation: 1
This is my shell script (automate_test.sh):
#!/bin/bash
cp -i ball1.rtf container
cp -i ball2.rtf container
cp -i ball3.rtf container
This is the input file for this script (in_test.txt):
n
y
n
And, I am executing this command :
cat "in_test.txt" | ./automate_test.sh
Folder named "container" already contains files named "ball1.rtf","ball2.rtf" and "ball3.rtf" Expected behaviour is that only ball2 should be overwritten. But output is as follows :
overwrite container/ball1.rtf? (y/n [n]) not overwritten
overwrite container/ball2.rtf? (y/n [n]) not overwritten
overwrite container/ball3.rtf? (y/n [n]) not overwritten
Upvotes: 0
Views: 175
Reputation: 14491
Instead of trying to "talk" with interactive program using static file, consider letting 'cp' know which file to override with command line options:
Remember that cp will not prompt for overwrite if the file does not exists, which will cause mismatch between questions and answers.
Upvotes: 1