|
|
![]() |
|
|
|
|
||
|
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
|
Editors
Contact the Editors |
| Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |