I've got a Bash script that prompts for a 'y/n' response and works perfectly when I run it locally. However, when I try to execute it using curl like this: `curl -sSL https://url.com/test.sh | bash -x`, it keeps returning an 'invalid response' message, even if I give a valid response. I don't understand why it behaves this way when run through curl versus running it directly. What could be going wrong?
2 Answers
First off, what does the URL actually output when you curl it? If you run `curl -sSL https://url.com/test.sh`, you'll see the script itself. That way you can check it's what you expect.
Running scripts like that with curl can be risky! When you use pipes, the script is cut off from the terminal interaction it needs. Essentially, it’s not able to read input from stdin. If you want to run it like this safely, consider using process substitution instead. For example: `bash -x <(curl -sSL https://url.com/test.sh)`. This will give your script proper access to the terminal.
Thanks for the tip! I'll try that!