How to send enter 4 times in batch file?
I am going to use AWS CLI to control AWS resources automatically on windows. But I find the problem with AWS configure to press enter from cmd to run the next command. How do I automatically press enter from the .bat? Thanks for your help.
for example,
C:\>aws configure
AWS Access Key ID [AKIAIOSFODNN7****]: (press enter)
AWS Secret Access Key [wJalrXUtnFEMI/K7MDENG/bPxRfiC**]: (press enter)
Default region name [us-west-2]: (press enter)
Default output format [json]: (press enter)
run next command.
To do this with pure cmd, you can create an empty textfile and place the 4 enters in there.
Now your command will be command < textfile
This basically means, run command
and use textfile as input. You can put other text inside the textfile too and it will enter that as keystrokes to the command as well as the enters.
So lets say you have the file C:\aws\enters.txt
that contains 4 enters, as such:
And your aws command is inside C:\aws too, you would type:
C:\>cd aws
C:\aws>aws configure < enters.txt