I guess your EC2 will need to expose an endpoint API for this to happen.
You might want to write another script using a high-level language (Python or Node.js are excellent examples with great Web-Api support), where this new script listens to a certain port number, and executes your underlying shell script upon request.
This would give you some flexibility in securing your endpoint if you wish, externally monitoring your script, and having any sort of statistical analysis on the request.
Another option would be to extend your original shell script to act as a server itself.
Ex.
while { echo -en "Received Request"; } | nc -l "${1:-8080}"; do
However this is less flexible with more room for security vulnerabilities.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…