Grammar refresher – Using punctuation properly

I’ve found that I often use colons in technical documentation and emails, yet I’ve probably never ‘really’ understood quite how they or semicolons should be used.  I think my school days were after the golden age of English Grammar education (or maybe I just didn’t pay attention).


After reading this, I’m now clear on the picture.  I could rephrase that as follows (just to force a semicolon in):


I read this article; I’m now clear on the picture, and shall use semicolons to appear clever.

PrevX – DeleteOld (eh?)

I just found that the top entry in google for ‘codebureau’ is actually some listing on prevx.com (which I’d never heard of) that’s seeming to suggest that DeleteOld (a console app I posted on CodeProject some time ago) is possibly spyware/malware – bloody cheek!  I’d be interested to know how this pops up on that tool, and also whether the .NET code has some flaws that means it can be used in a malicious way.  At least then I could defend myself.

Dynamic FTP Scripts

I seem to be getting back to basics at the moment with some of the things I’m doing – and didn’t imagine myself having to get an automated FTP update working this week…


My objective was to ‘get’ files from a remote machine using a folder pattern consisting of the date in an ‘yymmdd’ format.  I’d forgotten that script files used with ftp (ftp -s:myscript.txt) are dumb text files, and if you want to ‘get’ from a dynamic location – or dynamic filenames you need to magic something up.


My interest was sparked here, and although I found a C# FTP library on CodeProject that would clearly do the job, and would be cool to use in itself, I was more interested in using ‘old skool’ lo-tech methods to solve the problem.


I read one article that suggested using batch files to spit out the ftp script.  Excellent idea I thought – so this is what I ended up with…. (I’ve changed a few details to protect the innocent so if it doesn’t quite work it’s only due to my own typo 🙂 )


I won’t explain each bit as that would spoil the fun – but the general gist is that FTPReportsForDate is normally run without parameters and it finds files in a specific folder and renames them on the local host.  The process also does other stuff I didn’t have time to go into….


FTPReportsForDate.cmd (which accepts a parameter or gets current date if not supplied)


@echo off


echo Creating Log Folder
IF NOT EXIST C:\logs\FTP\ md c:\logs\FTP


echo Removing previous processing date
IF EXIST processingdate.txt del processingdate.txt /F


IF “%1” == “” (
 echo Getting current processing date
 cscript //NoLogo GetCurrentDate.vbs >> processingdate.txt
 echo Transferring File
 FOR /F %%f in (processingdate.txt) do CALL FTPCommand.cmd %%f
)


IF “%1” NEQ == “” (
 echo Transferring File
 CALL FTPCommand.cmd %1
)


FTPCommand.cmd  This constructs the FTP script file and does the FTP itself…


IF EXIST FTPLatestFile.txt del FTPLatestFile.txt /F


Type FTPHeader.txt >> FTPLatestFile.txt
echo cd RP%1.IN >> FTPLatestFile.txt
echo get staticfilename.fil dyn%1.fil >> FTPLatestFile.txt
echo close >> FTPLatestFile.txt
echo bye >> FTPLatestFile.txt


ftp -s:FTPLatestFile.txt >> c:\logs\ftp\transfer_%1.log


FTPHeader.txt This contains the static information used in the FTP script


open 192.168.0.1
myftpuser
myftppwd
prompt
lcd c:\incoming



GetCurrentDate.vbs
gets current date in a yymmdd format in the event we don’t pass in a date to FTPReportsForDate.cmd


‘Simple script to output todays date in yymmdd format for FTP processing


Function pd(n, totalDigits)
 if totalDigits > len(n) then
  pd = String(totalDigits-len(n),”0″) & n
 else
  pd = n
 end if
End Function


Wscript.echo pd(RIGHT(YEAR(date()),2),2) & pd(MONTH(date()),2) & pd(DAY(date()),2)
Wscript.echo
        

Back in the saddle

It’s been a good while since I wrote a blog entry.  So long in fact that my previous hosting provider (MSDNConnection) closed down without me even noticing!! (December 2005)

This did have the unfortunate side effect of removing all of my posts and so I lost the lot.  What did I learn?  err..  read your Hotmail occasionally rather than just using it to register for stuff on the web that you fear may cause your ‘real’ address to get spammed!

I’ll try and piece the content back together now I’ve got some space with ASPSpider.  DasBlog works extremely well here as it’s XML based and so I’ve got less chance of losing the lot if the rug’s pulled from under my feet again!

Better get to work then…