【问题标题】:call curl from rebol or red doesn't work从 rebol 或 red 调用 curl 不起作用
【发布时间】:2017-10-31 17:23:12
【问题描述】:

在 dos cmd 上这有效:

curl.exe -L https://dl.uxnr.de/build/curl/curl_winssl_msys2_mingw64_stc/curl-7.53.1/curl-7.53.1.zip > curl.zip

在 red 或 rebol 上,按照建议 Cannot read a binary file with red from http,我尝试了下面的代码,但它不起作用,为什么?

call {curl.exe -L https://dl.uxnr.de/build/curl/curl_winssl_msys2_mingw64_stc/curl-7.53.1/curl-7.53.1.zip > curl.zip}

我也试过呼叫/等待,它也不起作用。

【问题讨论】:

    标签: curl rebol red


    【解决方案1】:

    Rebol2:

    call/output {curl.exe -L https://www.example.com} data: make string! estimated-big-enough-number
    

    Rebol3(Ren/C 分支):

    call/shell/output {curl -L https://www.example.com} data: make binary! 0
    
    ;; or
    
    call/output [%/path/to/curl "-L" "https://www.example.com"] data: make binary! 0
    
    ;;or a poor mans solution as in e.g.
    
     call {curl -L -k https://dl.uxnr.de/build/curl/curl_winssl_msys2_mingw64_stc/curl-7.53.1/curl-7.53.1.zip  > this-I-want } data: read %this-I-want
    

    红色:

    call/output {curl -L -k https://dl.uxnr.de/build/curl/curl_winssl_msys2_mingw64_stc/curl-7.53.1/curl-7.53.1.zip} data: make binary! 100'000
    

    【讨论】:

    • 字符串?为什么在地球上,因为它是二进制文件:)
    • @user310291 也可以说data: make binary! ...
    • 我修改了答案,使其适用于 Red 和 Rebol2
    • 我的 R3 版本是 2.101.0.3.1 并且 'call 没有对 /shell 或 /output 进行改进。它只支持/等待。有关如何捕获从 cURL 返回的数据的任何提示?
    • 您可以尝试重定向,然后像 call "ls -l > this-I-want" data 中那样读取它:读取 %this-I-want
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-05
    • 1970-01-01
    • 2015-04-30
    • 2015-07-08
    • 1970-01-01
    相关资源
    最近更新 更多