You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

UDM-Pro上含curl的Bash命令失效问题排查求助

问题描述

在UDM-Pro上执行以下命令时出现错误:

dl_url=$(curl -fsL "https://api.github.com/repos/boostchicken-dev/udm-utilities/releases/latest" | awk '$0 ~ /"browser_download_url"/ {sub(/.*:\s*"/, "", $0); gsub("\"", "", $0); print $2}')
curl -Lo udm-boot_latest.deb $dl_url

执行后输出:

unifi-os shell
root@ubnt:/# dl_url=$(curl -fsL "https://api.github.com/repos/boostchicken-dev/udm-utilities/releases/latest" | awk '$0 ~ /"browser_download_url"/ {sub(/.:\s"/, "", $0); gsub(""", "", $0); print $2}')
root@ubnt:/# curl -Lo udm-boot_latest.deb $dl_url
curl: no URL specified! curl: try 'curl --help' or 'curl --manual' for more information
root@ubnt:/#

问题分析与解决方法
  • 问题原因:awk命令中最后使用print $2是错误的。GitHub API返回的JSON行在经过sub和gsub处理后,整个行内容就是完整的下载URL(无空格分割),此时$2为空值,导致dl_url变量没有获取到有效URL,因此curl命令报错。
  • 修改方案:将awk命令中的print $2改为print $0,这样就能正确输出处理后的完整URL。修改后的命令如下:
dl_url=$(curl -fsL "https://api.github.com/repos/boostchicken-dev/udm-utilities/releases/latest" | awk '$0 ~ /"browser_download_url"/ {sub(/.*:\s*"/, "", $0); gsub("\"", "", $0); print $0}')

执行上述修改后的命令后,再运行curl -Lo udm-boot_latest.deb $dl_url即可正常下载文件。

内容的提问来源于stack exchange,提问作者M-LAN

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 19:10:34