如何在shell脚本中使用curl? [英] How to use curl in a shell script?

查看:782
本文介绍了如何在shell脚本中使用curl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 #!/ bin / 

我尝试运行此shell脚本以便在Ubuntu框中安装RVM。 bash
RVMHTTP =https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer
CURLARGS = - f -s -S -k

bash< <(curl $ CURLARGS $ RVMHTTP)

但我得到以下错误


语法错误:重定向意外


,但是同样的结果,你能告诉我我错过了什么吗?

解决方案

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

#您可以将结果存储在变量
raw =$($ CURL $ CURLARGS $ RVMHTTP)

#或者你可以将它重定向到一个文件:
$ CURL $ CURLARGS $ RVMHTTP> / tmp / rvm-installer

或:



从网址执行bash脚本


I'm trying to run this shell script in order to install RVM in an Ubuntu box

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

bash < <(curl $CURLARGS $RVMHTTP)

but I get the following error

Syntax error: Redirection unexpected

Also tested not using the variables, but same result, could you tell what I'm missing?

解决方案

#!/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

or:

Execute bash script from URL

这篇关于如何在shell脚本中使用curl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆