cinder_bdt's Journal http://use.perl.org/~cinder_bdt/journal/ cinder_bdt's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:46:57+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 cinder_bdt's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~cinder_bdt/journal/ possibly helpful cmd file to ftp stuff http://use.perl.org/~cinder_bdt/journal/1810?from=rss <p>So I don't always program in Perl. Once a week, we have to do this, and I don't want everyone who uses this labor-saving device to come back to me for maintenance. Therefore it was easier to write it in Windows NT CMD.</p><p>Here it is in case it might be useful to others:</p><p>@echo off<br>SETLOCAL<nobr> <wbr></nobr>:: Download weekly DAT files from NAI to current directory.</p><p>for<nobr> <wbr></nobr>/f "tokens=1" %%I in ('time<nobr> <wbr></nobr>/t') do set _TGT_TIME=%%I<br>for<nobr> <wbr></nobr>/f "tokens=2" %%I in ('date<nobr> <wbr></nobr>/t') do set _TGT_DATE=%%I</p><p>SET _DATVER=%1<br>SET<nobr> <wbr></nobr>/A _INCREMENTAL=_DATVER - 1</p><p>SET _LOGFILE=getdat.txt<br>SET _FTPSITE=proxy.mysite.com<br>SET _FTPDIR=/pub/antivirus/datfiles/4.x<br>SET _FTPPASS=me@mysite.com<br>SET _FTPUSER=anonymous@ftp.nai.com<br>SET _FTPCOMMANDS=ftpcmds.txt</p><p>echo.<br>echo Download weekly DAT files from NAI to current directory.<br>echo usage: %0 ^<br>echo where: ^ is a 4 digit number, for example 4178<br>echo.<br>echo Session logged to "%CD%\%_LOGFILE%".<br>echo press Ctrl-C now if you don't want to run this.<br>pause</p><p>echo Download in progress.<nobr> <wbr></nobr>::first time writing to file, use only one arrow, to overwrite existing<br>echo open %_FTPSITE% &gt; %_FTPCOMMANDS%<br>echo %_FTPUSER%&gt;&gt; %_FTPCOMMANDS%<br>echo %_FTPPASS% &gt;&gt; %_FTPCOMMANDS%</p><p>echo binary &gt;&gt; %_FTPCOMMANDS%</p><p>echo get %_FTPDIR%/delta.ini &gt;&gt; %_FTPCOMMANDS%<br>echo get %_FTPDIR%/update.ini &gt;&gt; %_FTPCOMMANDS%<br>echo get %_FTPDIR%/%_INCREMENTAL%%_DATVER%.upd &gt;&gt; %_FTPCOMMANDS%<br>echo get %_FTPDIR%/dat-%_DATVER%.tar &gt;&gt; %_FTPCOMMANDS%<br>echo get %_FTPDIR%/dat-%_DATVER%.zip &gt;&gt; %_FTPCOMMANDS%<br>echo get %_FTPDIR%/sdat%_DATVER%.exe &gt;&gt; %_FTPCOMMANDS%</p><p>echo close &gt;&gt; %_FTPCOMMANDS%<br>echo quit &gt;&gt; %_FTPCOMMANDS%<nobr> <wbr></nobr>::first time writing to file, use only one arrow, to overwrite existing<br>echo. &gt; "%_LOGFILE%"<br>echo %_TGT_TIME%, %_TGT_DATE% &gt;&gt; "%_LOGFILE%"<br>echo. &gt;&gt; "%_LOGFILE%"<br>echo %0 was called with %* &gt;&gt; "%_LOGFILE%"<br>echo. &gt;&gt; "%_LOGFILE%"<br>echo Input file: &gt;&gt; "%_LOGFILE%"<br>echo. &gt;&gt; "%_LOGFILE%"<br>type %_FTPCOMMANDS% &gt;&gt; "%_LOGFILE%"<br>echo. &gt;&gt; "%_LOGFILE%"<br>echo Generated activity: &gt;&gt; "%_LOGFILE%"<br>echo. &gt;&gt; "%_LOGFILE%"<nobr> <wbr></nobr>::disable interactive prompting<nobr> <wbr></nobr>::enable debugging<nobr> <wbr></nobr>::use a command file<nobr> <wbr></nobr>::redirect STDERR to STDOUT<nobr> <wbr></nobr>::redirect STDOUT to append a log file<br>%SYSTEMROOT%\system32\ftp.exe -i -d -s:%_FTPCOMMANDS% &gt;&gt; "%_LOGFILE%" 2&gt;&amp;1<br>DEL %_FTPCOMMANDS%</p><p>echo Download complete.</p> cinder_bdt 2001-12-28T19:06:02+00:00 journal