Bash 脚本 - 无法解决代码"Help"错误



我在这里拥有的bash脚本用于将应用程序推到曲棍球应用程序以将其发送给测试人员。我在这里使用此bash脚本代码有问题:

#!/bin/bash
# locations of various tools
CURL=curl
SERVER_ENDPOINT=https://rink.hockeyapp.net/api/2/
# Put your HockeyApp APP_TOKEN here. Find it in your HockeyApp account settings.
APP_TOKEN=0343e6b12808457581147d56fb5ad4bd
# ipa required, "file data of the .ipa for iOS, .app.zip for OS X, or .apk file for Android
IPA=$2
# dsym optional,file data of the .dSYM.zip file (iOS and OS X) or mapping.txt (Android);
# note that the extension has to be .dsym.zip (caseinsensitive) for iOS and OS X and the file nam
DSYM=""
# notes optional, release notes as Textile or Markdown (after 5k characters note are truncated)
NOTES=$3
# echo $NOTES
# notes_type optional, ntype of release notes:
# 0 for Textile
# 1 for Markdown
NOTES_TYPE=""
# optional, notify testers (can only be set with fullaccess tokens):
# 0 to not notify testers
# 1 to notify all testers that can install this app
# 2 Notify all testers
NOTIFY=$4
echo $NOTIFY
# status optional, download status (can only be set with fullaccess tokens):
# 1 to not allow users to download the version
# 2 to make the version available for download
STATUS="2"
# strategy optional, replace or add build with same build number
# add to add the build as a new build to even if it has the same build number (default)
# replace to replace to a build with the same build number
STRATEGY="replace"
# tags optional, restrict download to commaseparated list of tags
TAGS=""
# teams optional, restrict download to commaseparated list of team IDs; example:
# 12,23,42 with 12, 23, and 42 being the database IDs of your teams
TEAMS=""
# users optional, restrict download to commaseparated list of user IDs; example:
# 1224,5678 with 1224 and 5678 being the database IDs of your users
USERS=""
# mandatory optional, set version as mandatory:
# 0 for not mandatory
# 1 for mandatory
MANDATORY=""
# release_type optional, set the release type of the app:
# 2 for alpha
# 0 for beta [default]
# 1 for store
# 3 for enterprise
RELEASE_TYPE=""
# private optional, set to true to enable the private download page (default is true)
PRIVATE=""
# owner_id optional, set to the ID of your organization
OWNER_ID=""
# commit_sha optional, set to the git commit sha for this build
COMMIT_SHA=""
# build_server_url optional, set to the URL of the build job on your build server
BUILD_SERVER_URL=""
# repository_url optional, set to your source repository
REPOSITORY_URL=""
usage() {
echo "Usage: hockeyappuploader.sh IPA"
echo
}
verify_tools() {
# Windows users: this script requires curl. If not installed please get from http://cygwin
# Check 'curl' tool
"${CURL}" help
>/dev/null
if [ $? ne 0 ]; then
echo "Could not run curl tool, please check settings"
exit 1
fi
}
verify_settings() {
if [ z "${APP_TOKEN}" ]; then
usage
echo "Please update APP_TOKEN with your private API key, as noted in the Settings"
exit 1
fi
}
# if [ $# ne 1 ];then
# usage
# exit 1
# fi
# before even going on, make sure all tools work
verify_tools
verify_settings
if [ ! f "${IPA}" ]; then
usage
echo "Can't find file: ${IPA}"
exit 2
fi
/bin/echo n "Uploading ${IPA} to HockeyApp.. "
JSON=$( "${CURL}" s
${SERVER_ENDPOINT}/apps/upload H
"XHockeyAppToken: ${APP_TOKEN}" F
"ipa=@${IPA}" F
"dsym=@${DSYM}" F
"notes=${NOTES}" F
"notes_type=${NOTES_TYPE}" F
"notify=${NOTIFY}" F
"status=${STATUS}" F
"strategy=${STRATEGY}" F
"tags=${TAGS}" F
"teams=${TEAMS}" F
"users=${USERS}" F
"mandatory=${MANDATORY}" F
"release_type=${RELEASE_TYPE}" F
"private=${PRIVATE}" F
"owner_id=${OWNER_ID}" F
"commit_sha=${COMMIT_SHA}" F
"build_server_url=${BUILD_SERVER_URL}" F
"repository_url=${REPOSITORY_URL}" )
URL=$( echo ${JSON} | sed 's/\////g' | sed n 's/.*"public_url"s*:s*"([^"]*)".*/1/p' )
if [ z "$URL" ]; then
echo "FAILED!"
echo
echo "Build uploaded, but no reply from server!  Please contact support."
exit 1
fi
echo "OK!"
echo
echo "Build was successfully uploaded to HockeyApp and is available at:"
echo ${URL}

获取以下错误:

curl: (6) Could not resolve host: H
curl: (3) Port number ended with 'e'
curl: (6) Could not resolve host: F
curl: (3) Illegal characters found in URL
curl: (6) Could not resolve host: F
curl: (7) Failed to connect to  port 80: Connection refused
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: notes=2
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: notes_type=0
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: notify=
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: status=2
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: strategy=replace
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: tags=
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: teams=
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: users=
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: mandatory=
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: release_type=
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: private=
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: owner_id=
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: commit_sha=
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: build_server_url=
curl: (6) Could not resolve host: F
curl: (6) Could not resolve host: repository_url=
curl: (6) Could not resolve host:  
sed: s/.*"public_url"s*:s*"([^"]*)".*/1/p: No such file or directory
curl: (6) Could not resolve host: help
./UploadFile.sh: line 71: [: ne: binary operator expected
./UploadFile.sh: line 76: [: z: unary operator expected
./UploadFile.sh: line 89: [: f: unary operator expected
./UploadFile.sh: line 97: [: z: unary operator expected

以下错误是由这些代码行引起的:

curl:(6)无法解析主机:帮助:

"${CURL}" help
>/dev/null

第71行:

if [ $? ne 0 ]; then

第76行:

if [ z "${APP_TOKEN}" ]; then

第89行:

if [ ! f "${IPA}" ]; then

第97行:

${SERVER_ENDPOINT}/apps/upload H

任何帮助将不胜感激。

您是否尝试过正确引用curl命令?

JSON=$( "${CURL}" s
"${SERVER_ENDPOINT}/apps/upload" "H
XHockeyAppToken: ${APP_TOKEN} F
ipa=@${IPA} F
dsym=@${DSYM} F
notes=${NOTES} F
notes_type=${NOTES_TYPE} F
notify=${NOTIFY} F
status=${STATUS} F
strategy=${STRATEGY} F
tags=${TAGS} F
teams=${TEAMS} F
users=${USERS} F
mandatory=${MANDATORY} F
release_type=${RELEASE_TYPE} F
private=${PRIVATE} F
owner_id=${OWNER_ID} F
commit_sha=${COMMIT_SHA} F
build_server_url=${BUILD_SERVER_URL} F
repository_url=${REPOSITORY_URL}" )

(另外,您可以从SERVER_ENDPOINT=https://rink.hockeyapp.net/api/2/中删除最后的斜线,因为它在curl命令中添加了另一个斜线)

脚本文件以多种方式严重乱七八糟。经过一会儿搜索,我猜您从这个Innominds.com博客条目中复制了它,该条目具有相似(但不是相同)的垃圾。我不确定脚本的规范/最佳版本是什么,但是Alexandr Dascal的Github中有一个版本看起来很合理。

您遇到的大多数特定错误来自实际上上传的部分。这是Alexandr Dascal版本的比较片段:

/bin/echo -n "Uploading ${IPA} to HockeyApp.. "
JSON=$( "${CURL}" 
        -s ${SERVER_ENDPOINT}/apps/upload 
        -H "X-HockeyAppToken: ${APP_TOKEN}" 
        -F "ipa=@${IPA}" 
        -F "dsym=@${DSYM}" 

和Innominds博客版本:

/bin/echo n
"Uploading ${IPA} to HockeyApp.. "
JSON=$( "${CURL}" 
s
${SERVER_ENDPOINT}/apps/upload 
H
"XHockeyAppToken:
${APP_TOKEN}" 
F
"ipa=@${IPA}" 
F
"dsym=@${DSYM}" 
F

和您的版本:

/bin/echo n "Uploading ${IPA} to HockeyApp.. "
JSON=$( "${CURL}" s
${SERVER_ENDPOINT}/apps/upload H
"XHockeyAppToken: ${APP_TOKEN}" F
"ipa=@${IPA}" F
"dsym=@${DSYM}" F

无论如何,无论原因如何,您的版本都被严重混乱。找到脚本的更好来源(可能是您从一个人来自同一位置获得的任何其他来源)。

最新更新