Question

Here is what I'm entering in Terminal:

curl --silent https://raw.githubusercontent.com/githubUser/repoName/master/installer.sh | bash

The WordPress installing bash script contains a "read password" command that is supposed to wait for users to input their MySQL password. But, for some reason, that doesn't happen when I run it with the "curl githubURL | bash" command. When I download the script via wget and run it via "sh installer.sh", it works fine.

What could be the cause of this? Any help is appreciated!

Was it helpful?

Solution

If you want to run a script on a remote server without saving it locally, you can try this.

#!/bin/bash
RunThis=$(lynx -dump http://127.0.0.1/example.sh)

if [ $? = 0 ] ; then
    bash -c "$RunThis"
else
    echo "There was a problem downloading the script"
    exit 1
fi

In order to test it, I wrote an example.sh:

#!/bin/bash
# File /var/www/example.sh
echo "Example read:"
read line
echo "You typed: $line"

When I run Script.sh, the output looks like this.

$ ./Script.sh 
Example read:
Hello World!
You typed: Hello World!

Unless you absolutely trust the remote scripts, I would avoid doing this without examining it before executing.

OTHER TIPS

It wouldn't stop for read: As when you are piping in a way you are forking a child which has been given input from parent shell. You cannot give the values back to parent(modify parent's env) from child. and through out this process you are always in parent process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top