2011-11-29 14 views
9

próbuję uruchomić ten skrypt w celu zainstalowania RVM w skrzynce UbuntuJak używać curl w skrypcie powłoki?

#!/bin/bash 
RVMHTTP="https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer" 
CURLARGS="-f -s -S -k" 

bash < <(curl $CURLARGS $RVMHTTP) 

ale pojawia się następujący błąd

Syntax error: Redirection unexpected

Również nie testowano przy użyciu zmiennych, ale sam wynik , możesz powiedzieć, czego mi brakuje?

+0

Twoje pytanie zostało już odpowiedział tutaj: http://stackoverflow.com/questions/5735666/execute-bash-script-from-url – favoretti

+0

Próbowałem go na moim mac i to działało dobrze. Domyślam się, że jest to bash Ubuntu (który moim zdaniem jest dash). Możesz sprawdzić stronę podręcznika dla myślnika. –

+0

'http: // linux.die.net/man/1/dash' –

Odpowiedz

14
#!/bin/bash                                              
CURL='/usr/bin/curl' 
RVMHTTP="https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer" 
CURLARGS="-f -s -S -k" 

# you can store the result in a variable 
raw="$($CURL $CURLARGS $RVMHTTP)" 

# or you can redirect it into a file: 
$CURL $CURLARGS $RVMHTTP > /tmp/rvm-installer 

czyli

Execute bash script from URL

4

Po pierwsze, Twój przykład wygląda całkiem poprawny i działa dobrze na moim komputerze. Możesz pójść inną drogą.

curl $CURLARGS $RVMHTTP > ./install.sh 

Wszystko wyjście teraz przechowywania w ./install.sh pliku, który można edytować i wykonać.

4
url=”http://shahkrunalm.wordpress.com“ 
content=”$(curl -sLI “$url” | grep HTTP/1.1 | tail -1 | awk {‘print $2′})” 
if [ ! -z $content ] && [ $content -eq 200 ] 
then 
echo “valid url” 
else 
echo “invalid url” 
fi 
Powiązane problemy