Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2012
    Messaggi
    12

    [batch (.bat)] Prelevare e inviare file FTP o E-MAIL

    Salve,
    vorrei chiedervi aiuto per la creazione di un file .bat che dovrebbe:
    -Prelevare un files chiamato esempio.cfg (contenuto nella stessa cartella dov'è il files .bat)
    - inviarlo tramite ftp o tramite mail.
    io ho iniziato a fare lo script
    codice:
    @ECHO OFF
    SETLOCAL EnableExtensions
     
    REM Connection information:
    SET Server=mieidati
    SET UserName=mieidati
    SET Password=mieidati
     
    REM ---- Do not modify anything below this line ----
     
    SET Commands="%TEMP%SendToFTP_commands.txt"
     
    REM FTP user name and password. No spaces after either.
    ECHO %UserName%> %Commands%
    ECHO %Password%>> %Commands%
     
    REM FTP transfer settings.
    ECHO binary >> %Commands%
     
    IF /I {%1}=={/L} (
       REM Add file(s) to the list to be FTP'ed.
       FOR /F "usebackq tokens=*" %%I IN ("%~dpnx2") DO ECHO put %%I >> %Commands%
    ) ELSE (
       ECHO put "%~dpnx1" >> %Commands%
    )
     
    REM Close the FTP connection.
    ECHO close  >> %Commands%
    ECHO bye    >> %Commands%
     
    REM Perform the FTP.
    FTP -d -i -s:%Commands% %Server%
     
    ECHO.
    ECHO.
     
    REM Clean up.
    IF EXIST %Commands% DEL %Commands%
    Con questo bisogna trascinare il file da inviare su questo .bat io invece vorrei che se trova il file loginsetting.cfg nella cartella dov'e il file .bat lo invia in automatico.
    Ma non so come fare

  2. #2
    Utente bannato
    Registrato dal
    Oct 2010
    Messaggi
    1,219

    Re: [batch (.bat)] Prelevare e inviare file FTP o E-MAIL

    Originariamente inviato da ecdl11
    Con questo bisogna trascinare il file da inviare su questo .bat io invece vorrei che se trova il file loginsetting.cfg nella cartella dov'e il file .bat lo invia in automatico.
    Ma non so come fare
    Non si è capito bene.
    Soprattutto la frase:
    "Con questo bisogna trascinare il file da inviare su questo .bat"
    Puoi spiegarti meglio?

  3. #3
    Utente di HTML.it
    Registrato dal
    Mar 2012
    Messaggi
    12
    con il mio script per inviare il file bisogna "trascinare" il file sopra lo script .bat io invece vorrei che se nella cartella dov'è il file .bat c'è un file chiamato loginsetting.cfg aprendo il file .bat lo uploadi tranquillamente facendo semplicemente doppioclik sul file .bat

  4. #4
    Se ho capito cosa vuoi fare puoi provare così:
    codice:
    @ECHO OFF
    SETLOCAL EnableExtensions
     
    REM Connection information:
    SET Server=mieidati
    SET UserName=mieidati
    SET Password=mieidati
     
    REM ---- Do not modify anything below this line ----
     
    SET Commands="%TEMP%SendToFTP_commands.txt"
     
    REM FTP user name and password. No spaces after either.
    ECHO %UserName%> %Commands%
    ECHO %Password%>> %Commands%
     
    REM FTP transfer settings.
    ECHO binary >> %Commands%
     
    IF EXIST loginsetting.cfg (
       REM Add file(s) to the list to be FTP'ed.
       FOR /F "usebackq tokens=*" loginsetting.cfg IN ("%~dpnx2") DO ECHO put loginsetting.cfg >> %Commands%
    ) ELSE (
       ECHO put "%~dpnx1" >> %Commands%
    )
     
    REM Close the FTP connection.
    ECHO close  >> %Commands%
    ECHO bye    >> %Commands%
     
    REM Perform the FTP.
    FTP -d -i -s:%Commands% %Server%
     
    ECHO.
    ECHO.
     
    REM Clean up.
    IF EXIST %Commands% DEL %Commands%
    Fammi sapere se funziona

    P.S. Ovviamente devi tenere il file cfg nella stessa directory del file bat
    sapientino regna sovrano

  5. #5
    Utente di HTML.it
    Registrato dal
    Mar 2012
    Messaggi
    12
    no, non funziona

  6. #6
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,472
    Penso sia meglio così

    codice:
    @ECHO OFF
    SETLOCAL EnableExtensions
     
    SET Server=mieidati
    SET UserName=mieidati
    SET Password=mieidati
     
    SET Commands="SendToFTP_commands.txt"
     
    IF EXIST loginsetting.cfg (
    ECHO %UserName%> %Commands%
    ECHO %Password%>> %Commands%
     
    ECHO binary >> %Commands%
     
    ECHO put loginsetting.cfg >> %Commands%
    
    ECHO close  >> %Commands%
    ECHO bye    >> %Commands%
     
    FTP -d -i -s:%Commands% %Server%
    )
     
    ECHO.
    ECHO.
     
    IF EXIST %Commands% DEL %Commands%
    No MP tecnici (non rispondo nemmeno!), usa il forum.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.