mgo
OS/400 Edition
Volume 3, Number 10 -- February 14, 2003

Commenting FTP Scripts



Dear Readers:

In the February 7 issue of Midrange Guru, I mentioned that I knew of no way to include comments in FTP scripts. Here are four methods that some of you shared with me.

--Ted


I place comments after the quit command.

--Thomas


I have to agree with your answer, but it may be possible to work around the problem. If the FTP server is an iSeries, you can send a "command," which consists entirely of a comment, as per the following example.


ftp> quote rcmd /* this is a comment */
250 Command /* this is a comment */ successful.
ftp>

--Terry


We have found the FTP NOOP command useful for the purpose of documentation. It sends the command to the FTP server, but that is harmless and the results are there for documentation in our FTP logs.

--Gary


We use PC batch files to run FTP. All batch files require the user to enter a user profile name and password as the second and third positional parameters. The batch files write the appropriate FTP commands to text files.

Building FTP scripts on the fly allows for in-program documentation and rudimentary on-screen prompting, and eliminates having to place user names and passwords in persistent scripts. User names and passwords do exist in the generated script files, but each batch file has a cleanup routine that deletes the generated script.

Here's an example:

@echo off
cls

REM -- Is user requesting help?
if %1==help  goto PARMWARN

REM -- Check for correct number of parameters
if %4x==x    goto PARMWARN

REM -- Check for ftpup.svf
if not exist ftpup.svf goto FILEWARN

REM -- Put up something for user to see
cls
echo.
echo    Running Product Upload...
echo.                              		       

REM -- Build ftp file as ftpcmd.txt
echo %2 > ftpcmd.txt
echo %3 >> ftpcmd.txt
echo bin >> ftpcmd.txt
echo QUOTE RCMD CRTLIB %4 >> ftpcmd.txt
echo QUOTE RCMD CRTSAVF %4/PRDPKG >> ftpcmd.txt
echo put ftpup.svf %4/FTPPKG >> ftpcmd.txt
echo QUOTE RCMD RSTLIB FTPPKG *SAVF SAVF(%4/FTPPKG) 
   RSTLIB(%4) MBROPT(*ALL) >> ftpcmd.txt
echo QUOTE RCMD SBMJOB CMD(CALL %4/SETUP PARM('%4')) 
   JOB(AUDIT) >> ftpcmd.txt
echo quit >> ftpcmd.txt

REM -- Execute ftp from ftpcmd.txt
ftp -s:ftpcmd.txt %1

REM -- Delete existing copy of ftpcmd.txt
echo Y|del ftpcmd.txt

REM -- Skip to end of program
cls
exit
goto ENDPGM

REM -- Display parameter warning / help
:PARMWARN
cls
echo.
echo    This program requires four input parameters.
echo.
echo    (1) System name
echo    (2) User profile name
echo    (3) Password
echo    (4) Library name.
echo.
pause
goto ENDPGM

REM -- Display file not found
:FILEWARN
cls
echo.
echo   File ftpup.svf was not found in your current directory. 
echo.  
pause
goto ENDPGM

REM -- End of program
:ENDPGM

I really enjoy your articles, especially those that make me look at things that I otherwise would not (e.g., utilities within QShell). Keep up the good work.

--Don


Sponsored By
SNAP-E BOOKS

Snap-eBooks is a new publishing company dedicated to the principle
that great products and tools do not have to cost a lot!

Snap-eBooks completely disagrees with the current industry practice that says that you should charge whatever the market will bear for AS/400 related products.

We believe that keeping the prices of our products low makes them accessible and affordable for everyone in our industry including programmers, operators, administrators, managers, and pretty much anyone else. After all, why should a book cost $89? At that price, only companies or corporations can afford them. Our low prices also mean that you can purchase however many eBooks you need, and get them when you need them.

Each eBook is full of step-by-step information that you can use to immediately learn a given topic in a short amount of time.

Download the Lightning-Guide eReader and then take a look at our sample eBook, called Introduction to Visual Age for RPG, and check it out for yourself just how useful our products really are.


THIS ISSUE
SPONSORED BY:

ASC
Snap-E Books


BACK ISSUES

TABLE OF
CONTENTS

Easy Encryption with Exclusive Or

Commenting FTP Scripts

Reader Feedback and Insights: Odds and Ends



Editors
Howard Arner
Joe Hertvik
Ted Holt
David Morris

Managing Editor
Shannon Pastore

Publisher and
Advertising Director:

Jenny Thomas

Advertising Sales Representative
Kim Reed

Contact the Editors
Do you have a gripe, inside dope or an opinion?
Email the editors:
editors@itjungle.com

Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.