Alex Thomson
Alex Thomson

Reputation: 143

How to simulate pressing enter in a bash script

This is my first bash script. I want to run a script five times, the script is located in the same folder that this script will be located. My problem is that I cannot find how to simulate pressing enter. Since this script needs to load the data first it takes two seconds after running it, then it prompts you to press enter. I want to simulate doing this five times. How can I do the 3 second delay and press enter after? Any other problems with my script?

#!/bin/bash

for i in {1..5}
do
   ./clientScript.py
   #Press enter after a 3 second pause
done

Upvotes: 0

Views: 3763

Answers (1)

Jason Hu
Jason Hu

Reputation: 6333

this should work:

echo | ./clientScript.py

it simply outputs a \n to the stdin of your python script.

Upvotes: 2

Related Questions