Tuesday, January 30, 2007

Sample Code: Shell function

In the forum, some one asked how he can download a file from a web server
via lotus script. It hit me. I have exactly almost the same function, but I
download from a ftp server instead of a web server. But, it almost the
same.

Actually lotus script - as far as I know - doesn't provide function for
that. So, I look elsewhere, then I found a very interesting function call
shell.

From Designer Help, description about shell function is very short - Starts
another program - that it, no more no less.

Later I found out that shell can 'almost' run anything via command line,
like my agent that called an ftp program to download or upload a file.

Sample of my agent:
Dim TaskID as integer
TaskID = Shell ("c:\programto\download.bat")

Than I create a batch file called download.bat
ftp.exe -i -s:"c:\programto\download.txt">c:\jbadownload\log\getsO13Log.txt

Than I create a download.txt
open ftp.server.com
ftpusername
ftpusepassword
ascii
prompt
cd tosomefolder
lcd tosomelocalfolder
get somefile
bye

See the tricks?

I don't use any third party ftp client, just using ftp client that already
included in all windows distribution. That's works.

I also use the shell function to do many things, like extract zip files
with pkunzip and many more.

0 comments:

Template Designed by Douglas Bowman - Updated to Beta by: Blogger Team
Modified for 3-Column Layout by Hoctro