如何为Apple iTMS Transporter安装程序传递--accept许可参数?
解决iTMS Transporter安装脚本
--accept参数不生效的问题 问题场景
在Linux系统上下载并执行Apple iTMS Transporter安装脚本时,尝试通过传递--accept参数跳过手动接受许可协议,但执行后仍被提示输入确认。
执行的命令:
wget -O iTMSTransporter_installer_linux_3.2.sh "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/resources/download/public/Transporter__Linux/bin"
./iTMSTransporter_installer_linux_3.2.sh --accept
脚本相关源码片段
参数解析部分
initargs="$@" while true do case "$1" in -h | --help) MS_Help exit 0 ;; -q | --quiet) quiet=y noprogress=y shift ;; --accept) accept=y shift ;; --info)
许可协议打印函数部分
MS_PrintLicense() { PAGER=${PAGER:=more} if test x"$licensetxt" != x; then PAGER_PATH=`exec <&- 2>&-; which $PAGER || command -v $PAGER || type $PAGER` if test -x "$PAGER_PATH"; then echo "$licensetxt" | $PAGER else echo "$licensetxt" fi if test x"$accept" != xy; then while true do MS_Printf "Please type y to accept, n otherwise: " read yn if test x"$yn" = xn; then keep=n eval $finish; exit 1 break; elif test x"$yn" = xy; then break; fi done
问题分析
从给出的源码来看,--accept参数确实会设置accept=y,但仍触发手动确认的原因可能有两点:
- 变量作用域问题:
accept变量在主脚本的参数解析循环中定义,若MS_PrintLicense函数未正确继承该变量(比如脚本启用了set -u,或变量未全局生效),函数内部的$accept会为空,导致进入手动确认流程。 - 参数解析不完整:提供的参数解析代码片段中
--info分支未处理,可能后续存在未展示的逻辑,导致参数解析循环未正常结束,--accept参数未被正确识别。
解决方法
- 方法1:通过环境变量传递
accept值
直接将accept=y作为环境变量传入脚本,强制函数内部识别该变量:accept=y ./iTMSTransporter_installer_linux_3.2.sh - 方法2:组合使用静默与接受参数
尝试同时添加--quiet参数,跳过许可协议展示并自动接受:./iTMSTransporter_installer_linux_3.2.sh --quiet --accept - 方法3:管道自动输入确认指令
若上述方法无效,通过管道自动输入y绕过手动确认:echo "y" | ./iTMSTransporter_installer_linux_3.2.sh - 方法4:检查完整参数解析逻辑
查看脚本完整的参数解析循环,确认是否存在默认分支(如*) break;;),确保--accept参数被处理后循环能正常退出。
内容的提问来源于stack exchange,提问作者Zvi
相关产品推荐
相关产品推荐

