script for uploading files to a FTP server

Kezdőlap Fórumok Programozás script for uploading files to a FTP server

10 bejegyzés megtekintése - 11-20 / 29
  • Szerző
    Bejegyzés
  • #2148810
    ELaci
    Felhasználó

      Ú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
      VEGE

      Nyilvá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

      #2148811
      ELaci
      Felhasználó

        Ú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
        VEGE

        Nyilvá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

        #2148812
        tamsa
        Felhasználó

          #!/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 $FTPS

          tar.hu-n mux

          #2148813
          tamsa
          Felhasználó

            #!/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 $FTPS

            tar.hu-n mux

            #2148814
            kayapo
            Felhasználó

              Nincs 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%5D

              Startup:
                -V, –version     Display the version of wput and exit.
                -h, –help   Print this help-screen
                -b, –background go to background after startup

              Logging 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 upload

              Upload:
                –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 PASS

              FTP-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 TLS

              See wput(1) for more detailed descriptions of the options.
              Report bugs and suggestions via SourceForge at
              http://sourceforge.net/tracker/?group_id=141519

              tehá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@seth
              #2148815
              kayapo
              Felhasználó

                Nincs 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%5D

                Startup:
                  -V, –version     Display the version of wput and exit.
                  -h, –help   Print this help-screen
                  -b, –background go to background after startup

                Logging 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 upload

                Upload:
                  –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 PASS

                FTP-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 TLS

                See wput(1) for more detailed descriptions of the options.
                Report bugs and suggestions via SourceForge at
                http://sourceforge.net/tracker/?group_id=141519

                tehá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@seth
                #2148816
                tamsa
                Felhasználó

                  De túl van lihegve, de az miért baj ?

                  #2148817
                  tamsa
                  Felhasználó

                    De túl van lihegve, de az miért baj ?

                    #2148818
                    kayapo
                    Felhasználó

                      Ez igaz 😀

                      Na mindegy, Én azért a wput -ot használnám, ez tulajdonképpen erre való (szvsz)

                      #2148819
                      kayapo
                      Felhasználó

                        Ez igaz 😀

                        Na mindegy, Én azért a wput -ot használnám, ez tulajdonképpen erre való (szvsz)

                      10 bejegyzés megtekintése - 11-20 / 29
                      • Be kell jelentkezni a hozzászóláshoz.