Re: Command line FTP help



You already had most of the important elements - nice job!
In the version below I added a script generator that will
process your input parameters. I also streamlined things
a little bit to make the code shorter and more robust.

@echo off
rem Version 1.0

if (%1)==() GOTO NOPARAM1
if (%2)==() GOTO NOPARAM2

set site=xxx.yyyyyyy.co.uk
set user=username
set pass=password
set source=%1
set target=%2
set script=C:\Gnupg\FTP_Steps.txt
set log=C:\Gnupg\SecureFTP.log

echo>%script% %user%
echo>>%script% %pass%
echo>>%script% binary
echo>>%script% put %target%
echo>>%script% quit

rem This part of the program encrypts the input file and produces an
encrypted output file

gpg --armor --output %target% --recipient XXXXXXXX --encrypt %source% &&
goto FTP
echo ------------------------------------------------------------------- >>
%log%
echo %date% %time:~0,5% >> %log%
echo An error occured whilst encrypting the file >> %log%
echo ------------------------------------------------------------------- >>
%log%

GOTO :eof

rem This part of the program transfers the encrypted file using FTP

:FTP
echo ------------------------------------------------------------------- >>
%log%
echo %date% %time:~0,5% >> %log%
FTP.EXE -i -n -d -s:%script% %site% >> %log% && goto :eof
echo ------------------------------------------------------------------- >>
%log%
echo %date% %time:~0,5% >> %log%
echo An error occured during the FTP transfer >> %log%
echo ------------------------------------------------------------------- >>
%log%

GOTO END

:NOPARAM1
echo ------------------------------------------------------------------- >>
%log%
echo %date% %time:~0,5% >> %log%
echo The input (unencrypted) filename did not get passed to the program >>
%log%
echo ------------------------------------------------------------------- >>
%log%

:NOPARAM2
echo ------------------------------------------------------------------- >>
%log%
echo %date% %time:~0,5% >> %log%
echo The output (encrypted) filename did not get passed to the program >>
%log%
echo ------------------------------------------------------------------- >>
%log%


"Jake" <Jake@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4F4EF454-174B-4438-82B9-4804A323AB67@xxxxxxxxxxxxxxxx
> OK here is the batch program:
>
>
> @echo off
> rem Version 1.0
> rem
> if (%1)==() GOTO NOPARAM1
> if (%2)==() GOTO NOPARAM2
>
> rem This part of the program encrypts the input file and produces an
> encrypted output file
>
> gpg --armor --output %2 --recipient XXXXXXXX --encrypt %1
> if not errorlevel 1 goto FTP
> echo -------------------------------------------------------------------
>>
> C:\Gnupg\SecureFTP.log
> date /t >> C:\Gnupg\SecureFTP.log
> time /t >> C:\Gnupg\SecureFTP.log
> echo An error occured whilst encrypting the file >> C:\Gnupg\SecureFTP.log
> echo -------------------------------------------------------------------
>>
> C:\Gnupg\SecureFTP.log
>
> GOTO END
>
> rem This part of the program transfers the encrypted file using FTP
>
> :FTP
> echo -------------------------------------------------------------------
>>
> C:\Gnupg\SecureFTP.log
> date /t >> C:\Gnupg\SecureFTP.log
> time /t >> C:\Gnupg\SecureFTP.log
> C:\Windows\system32\FTP.EXE -i -n -d -s:C:\Gnupg\FTP_Steps.txt >>
> C:\Gnupg\SecureFTP.log
> if not errorlevel 1 goto END
> echo -------------------------------------------------------------------
>>
> C:\Gnupg\SecureFTP.log
> date /t >> C:\Gnupg\SecureFTP.log
> time /t >> C:\Gnupg\SecureFTP.log
> echo An error occured during the FTP transfer >> C:\Gnupg\SecureFTP.log
> echo -------------------------------------------------------------------
>>
> C:\Gnupg\SecureFTP.log
>
> GOTO END
>
> :NOPARAM1
> echo -------------------------------------------------------------------
>>
> C:\Gnupg\SecureFTP.log
> date /t >> C:\Gnupg\SecureFTP.log
> time /t >> C:\Gnupg\SecureFTP.log
> echo The input (unencrypted) filename did not get parsed to the program >>
> C:\Gnupg\SecureFTP.log
> echo -------------------------------------------------------------------
>>
> C:\Gnupg\SecureFTP.log
>
> :NOPARAM2
> echo -------------------------------------------------------------------
>>
> C:\Gnupg\SecureFTP.log
> date /t >> C:\Gnupg\SecureFTP.log
> time /t >> C:\Gnupg\SecureFTP.log
> echo The output (encrypted) filename did not get parsed to the program >>
> C:\Gnupg\SecureFTP.log
> echo -------------------------------------------------------------------
>>
> C:\Gnupg\SecureFTP.log
>
> :END
>
>
> Here is the FTP_Steps file:
>
> open xxx.yyyyyyy.co.uk
> user username password
> put %2
> quit


.



Relevant Pages

  • Re: dos batch programmer help!!
    ... REM Set up your two serial numbers here and ensure dir C:\TEMP\ exists ... if errorlevel 1 goto otherdisk ... echo Wrong diskin H: -- swap it to allow backup to continue! ...
    (comp.os.msdos.programmer)
  • Re: Compiled ocx file reports different sizes
    ... Rem Set Resource Compiler path ... goto checkMIDL ... echo VC_HOME is set incorrectly. ... echo Step 2: Compiling Resource file ...
    (microsoft.public.vc.mfc)
  • Re: dos batch programmer help!!
    ... REM Set up your two serial numbers here and ensure dir C:\TEMP\ exists ... if errorlevel 1 goto otherdisk ... echo Wrong diskin H: -- swap it to allow backup to continue! ...
    (comp.os.msdos.programmer)
  • Re: Command line FTP help
    ... if ==GOTO NOPARAM1 ... rem This part of the program encrypts the input file and produces an ... echo An error occured whilst encrypting the file>> C:\Gnupg\SecureFTP.log ...
    (microsoft.public.win2000.networking)
  • [EXPL] MS-SQL Vulnerability Exploiting Trusted Connections
    ... rem Scan networks for SQL servers that allow access via db guest account ... Echo Ping Testing %2 ... If Not %Guest_Vulnerable%==Yes Goto Checks_Done ...
    (Securiteam)