frindly
Goto Top

Shell Script für FTP Upload

Suche eine möglichkeit per Script Dateien auf einen FTP Server zu laden

Hallo,
ich suche nach einer Möglichkeit mittels Shell Script Dateien auf einen FTP Server zu laden,
so das ich diese Möglichkeit in meine Backupprogramme einbinden kann.
Der FTP Server steht hinter einem Proxy, so das hier dann auch noch eine Authenthifizierung nötig währe.

Content-Key: 147298

Url: https://administrator.de/contentid/147298

Ausgedruckt am: 28.03.2024 um 21:03 Uhr

Mitglied: hajowe
hajowe 21.07.2010 um 08:27:46 Uhr
Goto Top
Beispiel:
filename="/home/paul/myfile.tar.gz"  
hostname="ftp.myhost.com"  
username="username"  
password="password"  
ftp -un $hostname <<EOF
quote USER $username
quote PASS $password

binary
put $filename
quit
EOF
Mitglied: frindly
frindly 21.07.2010 um 09:03:37 Uhr
Goto Top
Das sieht schon so aus wie das was ich suche.
Der Ziel Rechner steht aber hinter einemFTP Proxy.
Mitglied: hajowe
hajowe 21.07.2010 um 10:37:13 Uhr
Goto Top
Beispiel mit Proxy:
#!/bin/sh
 
FTP_HOST=$1
FTP_NAME=$2
FTP_PASS=$3
 
SRC_FILE=$4
DST_FILE=$5
 
PROXY_SERVER=192.168.1.1
 
TMPFILE=`mktemp /tmp/ftptrans_remotels.XXXXXXXXXX`
 
if [ "$5" = "" ] ;  then  
        echo Ftp File Transfer via MAERSK proxy
        echo
        echo Usage:
        echo ftptrans.sh [FTP_HOST] [FTP_NAME] [FTP_PASS] [SRC_FILE] [DST_FILE]
        echo note that DST_FILE must be a file name without directories
        exit
fi
 
echo "FTP TRANSFER to $FTP_NAME@$FTP_HOST identified by $FTP_PASS"  
echo "tmp file is $TMPFILE"  
 
ftp -n  $PROXY_SERVER <<EOF
user $FTP_NAME@$FTP_HOST $FTP_PASS
binary
put $SRC_FILE $DST_FILE
ls . $TMPFILE
bye
EOF
 
cat $TMPFILE | if grep $DST_FILE ; then
        echo Done
        exit 0
else
        echo Error
        exit 1
fi