Kezdőlap › Fórumok › Programozás › script for uploading files to a FTP server
- This topic has 28 hozzászólás, 7 résztvevő, and was last updated 17 years, 6 months telt el by
tamsa.
-
SzerzőBejegyzés
-
2008-01-06-11:45 #2148810
Úgy is lehet indítani az ftp -t mintha interaktív lenne, viszont nem az.
Én pl. így oldottam meg:Code:ftp -n 1.1.1.1 <<VEGE
user ftp-user ftp-pwd
put /dir/ahonnan/kell/file1 celfile1
put /dir/ahonnan/kell/file2 celfile2
bye
VEGENyilván a put helyett az mput is jó, mert a két „VEGE” közötti utasításokat interaktívként kezeli, és ezeket az utasításokat létre is lehet hozni futás közben.
Ez a fajta megoldás azért is jó mert csak egyszer kell indítani az ftp -t.
Egyébként meg sokféle más program is létezik ftp megoldásokra. Én pl. a „curl” nevűt ismerem még.
(Az 1.1.1.1 a célgép IP címe.)EL
2008-01-06-11:45 #2148811Úgy is lehet indítani az ftp -t mintha interaktív lenne, viszont nem az.
Én pl. így oldottam meg:Code:ftp -n 1.1.1.1 <<VEGE
user ftp-user ftp-pwd
put /dir/ahonnan/kell/file1 celfile1
put /dir/ahonnan/kell/file2 celfile2
bye
VEGENyilván a put helyett az mput is jó, mert a két „VEGE” közötti utasításokat interaktívként kezeli, és ezeket az utasításokat létre is lehet hozni futás közben.
Ez a fajta megoldás azért is jó mert csak egyszer kell indítani az ftp -t.
Egyébként meg sokféle más program is létezik ftp megoldásokra. Én pl. a „curl” nevűt ismerem még.
(Az 1.1.1.1 a célgép IP címe.)EL
2008-01-06-14:09 #2148812#!/bin/sh
#konyvrár struktúra felmásolása
#váltzók beállítása
FTPU=ftpusername
FTPP=Ftpuserpass
FTPH=ftphost
LOCD=utvonal/a/masoladno/konyvtarhoz
FTPD=/utvonal/a/alapkonyvtaroz
FTPS=/tmp/ftpcont.$$
echo ftp script generálása ...
if [ -d $LOCD ]
then
echo open $FTPH >>$FTPS
echo user $FTPU $FTPP >>$FTPS
cd $LOCD
echo cd $FTPD >>$FTPS
for i in $(find . -type d)
do
echo mkdir $i >>$FTPS
done
for i in $(find . -type f)
do
echo put $i >>$FTPS
done
else
echo $LOCD nem létezik .... kilépés
exit 1
fi
echo by >>$FTPS
ftp -n <$FTPS
rm $FTPStar.hu-n mux
2008-01-06-14:09 #2148813#!/bin/sh
#konyvrár struktúra felmásolása
#váltzók beállítása
FTPU=ftpusername
FTPP=Ftpuserpass
FTPH=ftphost
LOCD=utvonal/a/masoladno/konyvtarhoz
FTPD=/utvonal/a/alapkonyvtaroz
FTPS=/tmp/ftpcont.$$
echo ftp script generálása ...
if [ -d $LOCD ]
then
echo open $FTPH >>$FTPS
echo user $FTPU $FTPP >>$FTPS
cd $LOCD
echo cd $FTPD >>$FTPS
for i in $(find . -type d)
do
echo mkdir $i >>$FTPS
done
for i in $(find . -type f)
do
echo put $i >>$FTPS
done
else
echo $LOCD nem létezik .... kilépés
exit 1
fi
echo by >>$FTPS
ftp -n <$FTPS
rm $FTPStar.hu-n mux
2008-01-06-15:13 #2148814Nincs ez egy kicsit túllihegve???
/bin/bash wrote:seth:~# wput –help
Usage: wput [options] [file]… [url]…
url ftp://%5Busername%5B:password%5D@%5Dhostname%5B:port%5D%5B/%5Bpath/%5D%5Bfile%5D%5DStartup:
-V, –version Display the version of wput and exit.
-h, –help Print this help-screen
-b, –background go to background after startupLogging and input file:
-o, –output-file=FILE log messages to FILE
-a, –append-output=FILE append log messages to FILE
-q, –quiet quiet (no output)
-v, –verbose be verbose
-d, –debug debug output
-nv, –less-verbose be less verbose
-i, –input-file=FILE read the URLs from FILE
-s, –sort sorts all input URLs by server-ip and path
–basename=PATH snip PATH off each file when appendig to an URL
-I, –input-pipe=COMMAND take the output of COMMAND as data-source
-R, –remove-source-files unlink files upon successful uploadUpload:
–bind-address=ADDR bind to ADDR (hostname or IP) on local host
-t, –tries=NUMBER set retry count to NUMBER (-1 means infinite)
-nc, –dont-continue do not resume partially-uploaded files
-u, –reupload do not skip already completed files
–skip-larger do not upload files if remote size is larger
–skip-existing do not upload files that exist remotely
-N, –timestamping don’t re-upload files unless newer than remote
-T, –timeout=10th-SECONDS set various timeouts to 10th-SECONDS
-w, –wait=10th-SECONDS wait 10th-SECONDS between uploads. (default: 0)
–random-wait wait from 0…2*WAIT secs between uploads.
–waitretry=SECONDS wait SECONDS between retries of an upload
-l, –limit-rate=RATE limit upload rate to RATE
-nd, –no-directories do not create any directories
-Y, –proxy=http/socks/off set proxy type or turn off
–proxy-user=NAME set the proxy-username to NAME
–proxy-pass=PASS set the proxy-password to PASSFTP-Options:
-p, –port-mode no-passive, turn on port mode ftp (def. pasv)
-A, –ascii force ASCII mode-transfer
-B, –binary force BINARY mode-transfer
–force-tls force the useage of TLSSee wput(1) for more detailed descriptions of the options.
Report bugs and suggestions via SourceForge at
http://sourceforge.net/tracker/?group_id=141519tehát:
Code:seth:~# wput -b -o ~/wput_log -t 3 -B -v ~/files/shrink_file.tgz ftp://user:pass@ftp.uw.hu/webroot/download/Beállítassz rá egy cron jobot, aztán hagy szaladjon, a kimenetet esetleg elküldetheted e-mailben valahogy így:
Code:seth:~# wput -b -t 3 -B -v ~/files/shrink_file.tgz ftp://user:pass@ftp.uw.hu/webroot/download/ | mailx -e -s ‘Napi feltöltés eredménye’ kayapo@seth2008-01-06-15:13 #2148815Nincs ez egy kicsit túllihegve???
/bin/bash wrote:seth:~# wput –help
Usage: wput [options] [file]… [url]…
url ftp://%5Busername%5B:password%5D@%5Dhostname%5B:port%5D%5B/%5Bpath/%5D%5Bfile%5D%5DStartup:
-V, –version Display the version of wput and exit.
-h, –help Print this help-screen
-b, –background go to background after startupLogging and input file:
-o, –output-file=FILE log messages to FILE
-a, –append-output=FILE append log messages to FILE
-q, –quiet quiet (no output)
-v, –verbose be verbose
-d, –debug debug output
-nv, –less-verbose be less verbose
-i, –input-file=FILE read the URLs from FILE
-s, –sort sorts all input URLs by server-ip and path
–basename=PATH snip PATH off each file when appendig to an URL
-I, –input-pipe=COMMAND take the output of COMMAND as data-source
-R, –remove-source-files unlink files upon successful uploadUpload:
–bind-address=ADDR bind to ADDR (hostname or IP) on local host
-t, –tries=NUMBER set retry count to NUMBER (-1 means infinite)
-nc, –dont-continue do not resume partially-uploaded files
-u, –reupload do not skip already completed files
–skip-larger do not upload files if remote size is larger
–skip-existing do not upload files that exist remotely
-N, –timestamping don’t re-upload files unless newer than remote
-T, –timeout=10th-SECONDS set various timeouts to 10th-SECONDS
-w, –wait=10th-SECONDS wait 10th-SECONDS between uploads. (default: 0)
–random-wait wait from 0…2*WAIT secs between uploads.
–waitretry=SECONDS wait SECONDS between retries of an upload
-l, –limit-rate=RATE limit upload rate to RATE
-nd, –no-directories do not create any directories
-Y, –proxy=http/socks/off set proxy type or turn off
–proxy-user=NAME set the proxy-username to NAME
–proxy-pass=PASS set the proxy-password to PASSFTP-Options:
-p, –port-mode no-passive, turn on port mode ftp (def. pasv)
-A, –ascii force ASCII mode-transfer
-B, –binary force BINARY mode-transfer
–force-tls force the useage of TLSSee wput(1) for more detailed descriptions of the options.
Report bugs and suggestions via SourceForge at
http://sourceforge.net/tracker/?group_id=141519tehát:
Code:seth:~# wput -b -o ~/wput_log -t 3 -B -v ~/files/shrink_file.tgz ftp://user:pass@ftp.uw.hu/webroot/download/Beállítassz rá egy cron jobot, aztán hagy szaladjon, a kimenetet esetleg elküldetheted e-mailben valahogy így:
Code:seth:~# wput -b -t 3 -B -v ~/files/shrink_file.tgz ftp://user:pass@ftp.uw.hu/webroot/download/ | mailx -e -s ‘Napi feltöltés eredménye’ kayapo@seth2008-01-06-15:38 #2148816De túl van lihegve, de az miért baj ?
2008-01-06-15:38 #2148817De túl van lihegve, de az miért baj ?
2008-01-06-15:56 #2148818Ez igaz 😀
Na mindegy, Én azért a wput -ot használnám, ez tulajdonképpen erre való (szvsz)
2008-01-06-15:56 #2148819Ez igaz 😀
Na mindegy, Én azért a wput -ot használnám, ez tulajdonképpen erre való (szvsz)
-
SzerzőBejegyzés
- Be kell jelentkezni a hozzászóláshoz.
legutóbbi hsz