请教一下各位大佬,我将Pyone的上传指令写到aria2的下载完成执行脚本里去,发现并没有执行上传。
但我手动运行脚本又是可以成功执行上传的,请教一下在sh里运行python有什么特殊的姿势吗?
能不能请大佬帮我看看
#!/bin/bash
GID="$1";
FileNum="$2";
File="$3";
MaxSize="157286400"
RemoteDIR="/Lixian/"; #上传到Onedrive的路径,默认为根目录,如果要上传到指定目录,方法看文章最后面。
LocalDIR="/root/download/"; #Aria2下载目录,记得最后面加上/
DiskFlag="A";
if [[ -z $(echo "$FileNum" |grep -o ‘[0-9]*’ |head -n1) ]]; then FileNum=’0′; fi
if [[ "$FileNum" -le ‘0’ ]]; then exit 0; fi
if [[ "$#" != ‘3’ ]]; then exit 0; fi
function LoadFile(){
IFS_BAK=$IFS
IFS=$’\n’
if [[ ! -d "$LocalDIR" ]]; then return; fi
if [[ -e "$File" ]]; then
if [[ $(dirname "$File") == $(readlink -f $LocalDIR) ]]; then
Option=" Upload";
else
Option=" UploadDir";
fi
FileLoad="${File/#$LocalDIR}"
while true
do
if [[ "$FileLoad" == ‘/’ ]]; then return; fi
echo "$FileLoad" |grep -q ‘/’;
if [[ "$?" == "0" ]]; then
FileLoad=$(dirname "$FileLoad");
else
break;
fi;
done;
if [[ "$FileLoad" == "$LocalDIR" ]]; then return; fi
# if [[ -n "$RemoteDIR" ]]; then
# Option=" -f $RemoteDIR";
# else
# Option="";
# fi
#="$(command -v $ONEDRIVE)";
EXEC1="python"
EXEC2="/root/PyOne/function.py"
if [[ -z "$EXEC1" ]]; then return; fi
cd "$LocalDIR";
if [[ -e "$FileLoad" ]]; then
ItemSize=$(du -s "$FileLoad" |cut -f1 |grep -o ‘[0-9]*’ |head -n1)
if [[ -z "$ItemSize" ]]; then return; fi
if [[ "$ItemSize" -ge "$MaxSize" ]]; then
echo -ne "\033[33m$File \033[0mtoo large to spik.\n";
return;
fi
eval "${EXEC1} ${EXEC2} ${Option}" \’"${LocalDIR}${FileLoad}"\’ \’"${RemoteDIR}"\’ \’"${DiskFlag}"\’;
if [[ $? == ‘0’ ]]; then
rm -rf "$FileLoad";
fi
fi
fi
IFS=$IFS_BAK
}
LoadFile;