Re: Command line FTP help
- From: "Pegasus \(MVP\)" <I.can@xxxxxxx>
- Date: Mon, 12 Dec 2005 23:33:20 +1100
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
.
- References:
- Re: Command line FTP help
- From: Pegasus \(MVP\)
- Re: Command line FTP help
- From: Jake
- Re: Command line FTP help
- Prev by Date: Re: DHCP errors 1010,1014 and 1016 after upgrading windows server 2003
- Next by Date: Re: DHCP errors 1010,1014 and 1016 after upgrading windows server 2003
- Previous by thread: Re: Command line FTP help
- Next by thread: Re: Command line FTP help
- Index(es):
Relevant Pages
|
|