我想知道为什么在我的shellcript下面写下“not found”错误,所以请告诉我我在代码中的错误(环境:mac OS X和CentOS6)ls和grep命令“找不到”shellcript中的错误
“xaf.sh”
#!/bin/sh
SERVER=$1
USER=$2
PASS=$3
FILE=$4
PATH=$5
echo $1
VAR=`ls | grep ${FILE}`
for one_file in ${VAR}; do
echo $one_file
echo "go"
touch ./ftp_err/log
ftp -nv 2>./ftp_err.log <<END
open $SERVER
user $USER $PASS
cd /$PATH
binary
prompt
put ${one_file}
exit
END
VAR2=`wc ./ftp_err.log`
if [VAR2 -gt 0 ] ; then
echo "you have an error in sending ${one_file}"
else
echo "you have succeeded Transfer of ${one_file}"
rm ${one_file}
fi
rm ./ftp_err.log
done
...并命令我如何发出和执行的结果如下(用户名和密码的部分被替代#)
**Command**
./xaf.sh 192.168.202.171 #r#####er c#####b## 2 /tmp/
**Result**
./xaf.sh: line 9: ls: command not found
./xaf.sh: line 9: grep: command not found
我成功使用LS,grep的代码,并为如下 #!/ bin/sh的写在 回声$ 1 FILE = $ 1 VAR ='LS |对于$ {VAR}中的one_file,grep $ {FILE}' ;做 echo $ one_file echo“go” done –
这是什么目的:''VAR ='ls | grep $ {FILE}'''?改为使用:'for *中的one_file $ file“*;做...' –