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

Printed on: April 26, 2024 at 10:04 o'clock

Member: hajowe
hajowe Jul 21, 2010 at 06:27:46 (UTC)
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
Member: frindly
frindly Jul 21, 2010 at 07:03:37 (UTC)
Goto Top
Das sieht schon so aus wie das was ich suche.
Der Ziel Rechner steht aber hinter einemFTP Proxy.
Member: hajowe
hajowe Jul 21, 2010 at 08:37:13 (UTC)
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