Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 从google drive下载数据的curl脚本出现异常_Shell_Curl_Download_Google Drive Api - Fatal编程技术网

Shell 从google drive下载数据的curl脚本出现异常

Shell 从google drive下载数据的curl脚本出现异常,shell,curl,download,google-drive-api,Shell,Curl,Download,Google Drive Api,我使用下面的脚本下载Darpa数据,这对我的安全研究很有用。此脚本将按正确的顺序下载文件,并最终使用md5sum对其进行验证。它在开始时工作正常,但当它结束时,我发现许多未能通过验证。我发现这个脚本下载的对应文件都是3103b,这很奇怪(它们不应该那么小,大小也不应该一样)。以下是来自zsh print的图片: 函数下载_文件(){ fileId=$2 文件名=$1 curl-sc/tmp/cookie”https://drive.google.com/uc?export=download&i

我使用下面的脚本下载Darpa数据,这对我的安全研究很有用。此脚本将按正确的顺序下载文件,并最终使用md5sum对其进行验证。它在开始时工作正常,但当它结束时,我发现许多未能通过验证。我发现这个脚本下载的对应文件都是3103b,这很奇怪(它们不应该那么小,大小也不应该一样)。以下是来自zsh print的图片:

函数下载_文件(){
fileId=$2
文件名=$1
curl-sc/tmp/cookie”https://drive.google.com/uc?export=download&id=${fileId}“>/dev/null
code=“$(awk'/_warning./{print$NF}'/tmp/cookie)”
卷曲-Lb/tmp/cookie“https://drive.google.com/uc?
export=download&confirm=${code}&id=${fileId}“-o${fileName}
}
函数下载列表(){
回声1美元
input=“$1/文件列表”
而IFS=读取-r行
做
#回音“$line”
项目=(美元行)
下载_文件“$1/${items[0]}”${items[1]}
完成<“$input”
} 
函数验证(){
input=“$1/bin.md5sum”
而IFS=读取-r行
做
#回音“$line”
项目=(美元行)
md5sumstring=`md5sum$1/${items[1]}`
md5sum=($md5sumstring[0])
如果[“$md5sum”=“${items[0]}”];则
echo“$md5sum的值为“${items[0]}”
其他的
回显“$1/${items[1]}无效”
fi
#下载_文件“$1/${items[0]}”${items[1]}
完成<“$input”
} 
下载列表“/engagent5/Data/cadets/”
下载列表“/Engagement5/Data/clearscope/”
下载列表“/engagent5/Data/fivedirections/”
下载列表“/Engagement5/Data/marple/”
下载列表“/engagent5/Data/theia/”
下载列表“/Engagement5/Data/trace/”
验证“/engagent5/Data/cadets/”
验证“/Engagement5/Data/clearscope/”
验证“/Engagement5/Data/fivedirections/”
验证“/Engagement5/Data/marple/”
验证“/engagent5/Data/theia/”
验证“/Engagement5/Data/trace/”

这些文件的预期大小大约是多少?
function download_file(){

fileId=$2
fileName=$1
curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=${fileId}" > /dev/null
code="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"  
curl -Lb /tmp/cookie "https://drive.google.com/uc?

export=download&confirm=${code}&id=${fileId}" -o ${fileName} 
}
function download_list(){
echo $1
input="$1/filelist"
while IFS= read -r line
do

# echo "$line"
items=($line)
download_file "$1/${items[0]}" ${items[1]}
done < "$input"
} 

function validate(){
    input="$1/bins.md5sum"
    while IFS= read -r line
    do

    # echo "$line"
    items=($line)
    md5sumstring=`md5sum $1/${items[1]}`
    md5sum=($md5sumstring[0])
    if [ "$md5sum" = "${items[0]}" ]; then
        echo "$md5sum has the value '${items[0]}'"
    else
        echo  "$1/${items[1]} is not valid"
    fi
    #download_file "$1/${items[0]}" ${items[1]}
    done < "$input"
} 

download_list "./Engagement5/Data/cadets/"
download_list "./Engagement5/Data/clearscope/"
download_list "./Engagement5/Data/fivedirections/"
download_list "./Engagement5/Data/marple/"
download_list "./Engagement5/Data/theia/"
download_list "./Engagement5/Data/trace/"

validate "./Engagement5/Data/cadets/"
validate "./Engagement5/Data/clearscope/"
validate "./Engagement5/Data/fivedirections/"
validate "./Engagement5/Data/marple/"
validate "./Engagement5/Data/theia/"
validate "./Engagement5/Data/trace/"