Freitag, 6. April 2007

ftp per scrip

###### variables ######

FTPFILE=".netrc" # file for access interactive
FTPCMD=".ftpcmd" # file for access interactive
FTPUSER="ftpuser" # ftp-username
FTPPW="password" # ftp-password
FTPHOST="FTPSERVER" # ftp-server



###### FTP backup ######

if [[ ! -f "~/$FTPFILE" ]]; then # if the ~/.netrc not exist, create it
/bin/echo "machine $FTPHOST login $FTPUSER password $FTPPW" > "~/$FTPFILE"
/bin/chmod 600 "~/$FTPFILE"
done

if [[ ! -f "~/$FTPCMD" ]]; then # if the ~/.ftpcmd not exist, create it, for interactive commads on ftp-sever
/bin/echo "passive" > "~/$FTPCMD"
/bin/echo "lcd $TEMPPATH" >> "~/$FTPCMD"
/bin/echo "mput *" >> "~/$FTPCMD"
/bin/echo "quit" >> "~/$FTPCMD"
/bin/chmod 600 "~/$FTPCMD"
done



/usr/bin/ftp -i $FTPHOST < ~/.$FTPCMD

if [[ $? = 0 ]]; then
exit
else
echo "Error in FTP Connection"
echo "Error-Code: $?"
done

Keine Kommentare:

Kommentar veröffentlichen