什么是 Windows bash 模拟 Linux sh 文件下载器?

发布于 2024-11-16 05:53:57 字数 396 浏览 5 评论 0原文

我尝试将 Linux 安装脚本移植到 Windows。在脚本中,我有文件下载,例如

ASL_DISTRO_SITE=surfnet.dl.sourceforge.net
BOOST_NAME=boost_1_44_0
BOOST_VERSION=1.44.0
    if [ ! -e $BOOST_DISTRO_NAME ]; then
        echo_run ${CURL_CMD} http://$ASL_DISTRO_SITE/project/boost/boost/$BOOST_VERSION/$BOOST_DISTRO_NAME -o $BOOST_DISTRO_NAME
    fi

如何将脚本的这部分移植到 windows .bat 语言?默认情况下有来自 MS 的实用程序吗?

I try porting linux setup script to windows. In script I have file download like

ASL_DISTRO_SITE=surfnet.dl.sourceforge.net
BOOST_NAME=boost_1_44_0
BOOST_VERSION=1.44.0
    if [ ! -e $BOOST_DISTRO_NAME ]; then
        echo_run ${CURL_CMD} http://$ASL_DISTRO_SITE/project/boost/boost/$BOOST_VERSION/$BOOST_DISTRO_NAME -o $BOOST_DISTRO_NAME
    fi

How to port such part of script to windows .bat language? Are there any utils coming from MS by default?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

锦欢 2024-11-23 05:53:57

您提供的代码中似乎缺少一些项目,但这是如何继续的最佳猜测:

set ASL_DISTRO_SITE=surfnet.dl.sourceforge.net
set BOOST_NAME=boost_1_44_0
set BOOST_VERSION=1.44.0
set BOOST_DISTRO_NAME = xxxx?
set CURL_CMD="c:\program files\curl\curl.exe" ???

cd %BOOST_BASE_DIR%  

if NOT EXISTS %BOOST_DISTRO_NAME% (
    %CURL_CMD% ^
       http://$ASL_DISTRO_SITE/project/boost/boost/%BOOST_VERSION%/%BOOST_DISTRO_NAME% ^
       -o %BOOST_DISTRO_NAME%
)

我没有简单的方法来测试它,所以如果它不起作用,请删除打开和关闭括号和延续字符“^”,并将所有 %CURL_CMD% ... 命令与 if NOT EXISTS ... 放在同一行。

因此,您需要提供 BOOST_BASE_DIR 的值(我已将其作为 var 添加到脚本中)、BOOST_DISTRO_NAME、CURL_CMD ....并且...您需要确定是否需要 echo_run,我不这么认为。对于 echo_run,您必须查看原始脚本。我猜想这是一个定义的函数,并且使用了eval。如果这是真的,上面的方法可能行不通。创建一个不带 IF NOT 测试的 bat 文件,但包含所有 set ... 变量和 %CURL_CMD%,运行该文件,然后添加上面的问题未能解决您的问题;-)

我希望这会有所帮助。

There seem to be a couple of missing items in the code you provide, but here is a best guess of how to proceed:

set ASL_DISTRO_SITE=surfnet.dl.sourceforge.net
set BOOST_NAME=boost_1_44_0
set BOOST_VERSION=1.44.0
set BOOST_DISTRO_NAME = xxxx?
set CURL_CMD="c:\program files\curl\curl.exe" ???

cd %BOOST_BASE_DIR%  

if NOT EXISTS %BOOST_DISTRO_NAME% (
    %CURL_CMD% ^
       http://$ASL_DISTRO_SITE/project/boost/boost/%BOOST_VERSION%/%BOOST_DISTRO_NAME% ^
       -o %BOOST_DISTRO_NAME%
)

I don't have an easy way to test this, so if it doesn't work, remove the open and close parens and the continuation char '^', and put all of the %CURL_CMD% ... command on the same line as the if NOT EXISTS ....

So, you need to provide values for BOOST_BASE_DIR (which I have added as a var to the script), BOOST_DISTRO_NAME, CURL_CMD .... AND ... you need to find out if you need echo_run, I don't think so. For echo_run, you have to look at your original script. I would guess that this is a function defined, and that is uses the eval. If that is true, the above may not work. Make a bat file without the IF NOT test, but with the all the set ... variables, and the %CURL_CMD%, run it and then add the output of the failure to you question above ;-)

I hope this helps.

绮筵 2024-11-23 05:53:57

此处下载 Windows 版 cURL

Download cURL for Windows from here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文