. $HOME/.profile
WORK_HOME="/data/log"
Login()
{
HOST_IP='12.25.79.1'
USRNM='xxx'
PWD='xxx'
REM_DIR='/data/raddata'
FILNM=xx
ret=`ftp -inv $HOST_IP >> ${WORK_HOME}/ftp.log <<!
user $USRNM $PWD
cd $REM_DIR
quit
!`
}
Login
ftp.log打印日誌:
230 User lcims logged in.
550 /data/raddata: A file or directory in the path name does not exist.
221 Goodbye.
通過搜索“A file or directory in the path name does not exist” 可以判斷遠程主機是否存在REM_DIR目錄。
去除ret=`ftp -inv $HOST_IP >> ${WORK_HOME}/ftp.log <<! 裏面的日誌ftp.log,就可以不寫日誌直接返回響應了。
注意:ftp的指令需要用下撇號括住,不然報錯。