我有这个 shell 脚本,但我不断收到奇怪的错误。其中一个是需要做的。另一个是 config.txt 没有找到,但我在 .sh 脚本的目录中有它。
这是错误打印输出:
jmgreen@jdev:~/citigetbash$ sh citiget.sh
: not found 2: clear
CITIGET
config.txt: No such file or directory
citiget.sh: 17: Syntax error: word unexpected (expecting "do")
这是目录的LS:
jmgreen@jdev:~/citigetbash$ ls
citiget.sh config.txt docs
这是我的shell脚本
#!/bin/bash
clear
strTitle="CITIGET"
echo $strTitle
#=====CONFIGURATION=============================================================
strLocalDir="/home/jmgreen/citigetbash/"
intMode=1
intTry=5
#===============================================================================
#
# ===== Read in all the URLs
strDir=$(pwd)
URLS=$(cat $strLocalDir"config.txt")
echo $URLS
# ===== Get the file
if [ $intMode = 1 ]; then
for u in $URLS;
do
# ===== Get the datestamp ready
ts=$(date +%Y%m%d%H%M%S);
echo "Trying..."$u
wget $u --no-check-certificate -t$intTry -a logfile.txt -O $strLocalDir"downloaded/"$ts".csv";
done
else
for u in $URLS;
do
# ===== Get the datestamp ready
ts=$(date +%Y%m%d%H%M%S);
wget $u -q --no-check-certificate -t$intTry -a logfile.txt -O $strLocalDir"downloaded/"$ts".csv";
done
fi
# ===== Clear Screen?
if [ $intMode = 1 ]; then
clear
fi
echo "===== DONE ====="
exit