发信人: qsecofr()
整理人: qsecofr(2000-10-21 23:08:07), 站内信件
|
【 在 yaoyuj (jyy) 的大作中提到: 】
: qsecofr兄,如果你找到在400上使用FTP批处理命令的资料的话,能不能
: 给我发一份,我也急着要。即便没有,你说的让400发送远程命令调用NT上的
: 批处理文件嵌套FTP -S命令才实现的文件自动下传的程序是怎么样的?能不能
: 给我一份,本人纯粹用于学习和作业,绝非商业用途,特地请教!
: ......
好吧,自己读吧,这几天特忙,被迫重操旧业,为客户写几个程序
ILE RPG + Delphi/400 :-( , 两年多没写过程序了耶。
下面是ftp批处理的详细方法和例子。过几天有时间了,我会整理,翻译
成中文,贴到精华区。 自己先读读吧。
FTP in Batch Mode
| FTP is designed as an interactive TCP/IP application. But with the A S/400 the
| user may run FTP in batch mode too. This is important for large file transfers or
| for file transfers in unattended mode.
To run FTP as a batch job, the following steps are required:
| 1. Create a CL program (or a REXX procedure) that starts FTP.
| 2. Provide a source physical file member with all those FTP commands that in
| interactive mode would be entered at the display station.
| 3. Submit a batch job that schedules and runs the CL program.
| 4. Check the results.
| The following example shows how to retrieve files from several remot e hosts to
| a central AS/400 in batch mode:
| 5.5.1.1 Create a CL program to start FTP
| 1. As the FTP command is an interactive command it must be changed f or use
| in batch environment:
| CHGCMD CMD(QSYS/FTP) ALLOW(*ALL)
| 2. FTP uses the display station for command INPUT and message OUTPUT . In
| batch mode, command input is provided by a source physical file memb er
| (here: FTPCMDS) and messages should be logged in an output file (her e
| FTPLOG) that may be checked visually or by a program for error messa ges.
| In the CL program use the OVRDBF command to overwrite these files wi th
| the ones to be used in batch:
| OVRDBF FILE(INPUT) TOFILE(PFEIFFER/QCLSRC) MBR(FTPCMDS)
| OVRDBF FILE(OUTPUT) TOFILE(PFEIFFER/QCLSRC) MBR(FTPLOG)
| 3. Call FTP in the CL program. The FTP command expects a host name o r
| internet address as a parameter before processing the input file wit h the FTP
| client subcommands. Use LOOPBACK as a ¢ dummy¢ host name for FTP, so
| total control of the FTP connections are placed in the FTP input fil e
| (FTPCMDS):
| FTP RMTSYS(LOOPBACK)
| FTP processes the input file and writes messages to the output file
| (FTPLOG).
| 4. After the FTP application ends, delete the overrides:
| DLTOVR FILE(INPUT OUTPUT)
| So the CL program for batch FTP will look like the following example on
| system RCHASM01:
| | | Columns . . . : 1 71 Browse PFEIFFER/QCLSRC
| SEU==> FTPBATCH
| FMT ** ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 . ..+... 7
| *************** Beginning of data ********************************** ***
| 0001.00 PGM
| 0002.00 CHGCMD CMD(QSYS/FTP) ALLOW(*ALL)
| 0003.00 OVRDBF FILE(INPUT) TOFILE(PFEIFFER/QCLSRC) +
| 0004.00 MBR(FTPCMDS)
| 0005.00 OVRDBF FILE(OUTPUT) TOFILE(PFEIFFER/QCLSRC) +
| 0006.00 MBR(FTPLOG)
| 0007.00 FTP RMTSYS(LOOPBACK) /* (FTP CL Program) */ ˙A.
| 0008.00 DLTOVR FILE(INPUT OUTPUT)
| 0009.00 ENDPGM
| ****************** End of data ************************************* ***
| F3=Exit F5=Refresh F9=Retrieve F10=Cursor F12=Cancel
| F16=Repeat find F24=More keys
| (C) COPYRIGHT IBM CORP. 1981, 1993. | |
| Figure 98. CL Program FTPBATCH for Batch FTP
| 5.5.1.2 Create the FTP Input File (FTPCMDS)
| This file has to contain all FTP client subcommands that would norma lly be
| entered in interactive mode through the display station. Subcommands such as
| user-id and password, puts and gets, and close. User HANS creates th e
| following file member FTPCMDS:
| | | Columns . . . : 1 71 Browse PFEIFFER/QCLSRC
| SEU==> FTPCMDS
| FMT ** ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 . ..+... 7
| *************** Beginning of data ********************************** ***
| 0001.00 hans hans ˙01.
| 0002.00 close ˙02.
| 0003.00 open rchrs001 ˙03.
| 0004.00 user root mozart ˙04.
| 0005.00 ascii ˙05.
| 0006.00 syscmd dltf file(hans/rs6) ˙06.
| 0007.00 get /tmp/ftpput.txt hans/rs6.rs6 ˙07.
| 0008.00 close ˙08.
| 0009.00 open mvax ˙09.
| 0010.00 user tester test ˙10.
| 0011.00 get [tester.hans]ftpput hans/vax.vax (replace ˙11.
| 0012.00 close ˙12.
| 0013.00 open rchasm02 ˙13.
| 0014.00 user hans hans ˙14.
| 0015.00 ebcdic ˙15.
| 0016.00 put hans/rs6.rs6 pfeiffer/rs6.rs6 ˙16.
| 0017.00 quote rcmd sndnetf file(pfeiffer/rs6) tousrid((pfeiffer rcha s149)) ˙17.
| 0018.00 close ˙18.
| 0019.00 quit ˙19.
| ****************** End of data ************************************* ***
| F3=Exit F5=Refresh F9=Retrieve F10=Cursor F12=Cancel
| F16=Repeat find F24=More keys | |
| Figure 99. FTP Client Subcommands (File Member FTPCMDS)
| Note: Explanation for FTP client subcommands in file FTPCMDS:
| ˙01. user-id and password for ¢ dummy¢ connection within client A S/400
| RCHASM01
| ˙02. close dummy connection in AS/400 RCHASM01
| ˙03. open control connection to RS/6000 RCHRS001
| ˙04. user user-id password (enter subcommand ¢ user¢!)
| ˙05. transfer ASCII data (will be translated on AS/400 to/from EBCD IC)
| ˙06. CL command to be run on client AS/400: delete file. Instead
| parameter ¢(replace¢ could be used with the next statement.
| ˙07. retrieve file from RS/6000
| ˙08. close control connection to RS/6000 RCHRS001
| ˙09. open connection to VAX MVAX
| ˙10. user user-id password (here: wrong password to produce an erro r
| message)
| ˙11. retrieve file from VAX replacing existing AS/400 file
| ˙12. close control connection to VAX MVAX
| ˙13. open control connection to remote AS/400 RCHASM02
| ˙14. user user-id password (enter subcommand ¢ user¢!)
| ˙15. transfer EBCDIC data (as it is from AS/400 to AS/400)
| ˙16. send AS/400 file to AS/400 RCHASM02 through TCP/IP
| ˙17. send this file from server AS/400 RCHASM01 to remote AS/400
| RCHAS149 through SNA network
| ˙18. close control connection to AS/400 RCHASM02
| ˙19. end FTP application
| 5.5.1.3 Create CL Program for Submitting the FTPBATCH Job
| In order to schedule the file transfers and run them unattended crea te a CL
| program that submits the FTPBATCH job. In the example the file trans fers are
| supposed to run the next Friday, 17:00 hour, in unattended mode. So user HANS
| creates the following CL program:
| | | Columns . . . : 1 71 Browse PFEIFFER/QCLSRC
| SEU==> FTPSUBMIT
| FMT ** ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 . ..+... 7
| *************** Beginning of data ********************************** ***
| 0001.00 PGM
| 0002.00 SBMJOB CMD(CALL PGM(PFEIFFER/FTPBATCH)) +
| 0003.00 JOB(FTPFRIDAY) OUTQ(PFEIFFER/PFEIFFER) +
| 0004.00 SCDDATE(*FRI) SCDTIME(170000) /* FTP for +
| 0005.00 Friday, 5:00 in the afternoon */
| 0006.00 ENDPGM
| ****************** End of data ************************************* ***
| F3=Exit F5=Refresh F9=Retrieve F10=Cursor F12=Cancel
| F16=Repeat find F24=More keys
| (C) COPYRIGHT IBM CORP. 1981, 1993. | |
| Figure 100. CP Program for Submitting Batch FTP Job.
| 5.5.1.4 Check the FTP Output File for Errors
| While running at the scheduled time FTP creates the data in file mem ber
| FTPLOG shown in Figure 101 on page 123.
| ˙A.
| Connecting to host system LOOPBACK at address 14.0.0.0 at port 21.
| 220-QTCP at RCHASM01.RCHLAND.
| 220 Connection will close if idle more than 5 minutes.
| Enter your userid to log on the remote host system.
| ˙01.
| >>>USER hans
| 331 Enter password.
| >>>PASS ********
| 230 HANS logged on.
| Enter an FTP command.
| ˙02.
| >>>Q U I T
| 221 QUIT subcommand received.
| Enter an FTP command.
| ˙03.
| Connecting to host system rchrs001 at address 9.5.69.198 at port 21.
| 220 rchrs001.rchland.ibm.com FTP server (Version 4.7 Tue Mar 09 17:3 9:34 CST
| 1993) ready.
| Enter an FTP command.
| ˙04.
| >>>USER root
| 331 Password required for root.
| >>>PASS ********
| 230 User root logged in.
| Enter an FTP command.
| ˙05.
| >>>T Y P E A
| 200 Type set to A; form set to N.
| Enter an FTP command.
| ˙06.
| Enter an FTP command.
| ˙07.
| >>>PORT 9,5,69,250,3,244
| 200 PORT command successful.
| >>>RETR /tmp/ftpput.txt
| 150 Opening data connection for /tmp/ftpput.txt (42500 bytes).
| 226 Transfer complete.
| 42750 bytes transferred in 3.580 seconds. Transfer rate 11.942 KB/se c.
| Enter an FTP command.
| ˙08.
| >>>Q U I T
| 221 Goodbye.
| Enter an FTP command.
| Figure 101 (Part 1 of 2). FTP Output (FTPLOG) After Running FTPBATCH Program
| ˙09.
| Connecting to host system mvax at address 9.5.8.252 at port 21.
| 220 FTP Service Ready
| Enter an FTP command.
| ˙10.
| >>>USER tester
| 331 User name TESTER received, please send password
| >>>PASS ********
| 530 User authorization failure
| Enter an FTP command.
| ˙11.
| You must first issue the USER command.
| Enter an FTP command.
| ˙12.
| >>>Q U I T
| 221 Goodbye.
| Enter an FTP command.
| ˙13.
| Connecting to host system rchasm02 at address 9.5.69.250 at port 21.
| 220-QTCP at RCHASM02.RCHLAND.IBM.COM.
| 220 Connection will close if idle more than 5 minutes.
| Enter an FTP command.
| ˙14.
| >>>USER hans
| 331 Enter password.
| >>>PASS ********
| 230 HANS logged on.
| Enter an FTP command.
| ˙15.
| >>>TYPE E
| 200 Representation type is EBCDIC nonprint.
| Enter an FTP command.
| ˙16.
| >>>PORT 9,5,69,250,3,247
| 200 PORT subcommand request successful.
| >>>STOR pfeiffer/rs6.rs6
| 150 Sending file to member RS6 in file RS6 in library PFEIFFER.
| 250 File transfer completed successfully.
| 42500 bytes transferred in 2.989 seconds. Transfer rate 14.219 KB/se c.
| Enter an FTP command.
| ˙17.
| >>>rcmd sndnetf file(pfeiffer/rs6) tousrid((pfeiffer rchas149))
| 250 Command sndnetf file(pfeiffer/rs6) tousrid((pfeiffer rchas149))
| successful.
| Enter an FTP command.
| ˙18.
| >>>Q U I T
| 221 QUIT subcommand received.
| Enter an FTP command.
| ˙19. (This ends the FTP application)
| Figure 101 (Part 2 of 2). FTP Output (FTPLOG) After Running FTPBATCH Program
| This output should be checked for errors that might have occurred du ring FTP
| processing either visually or by a program testing for error return codes. Three
| digit FTP error return codes start with 4 or 5. For a list of FTP re turn codes refer
| to Appendix B, “FTP Return Codes” on page 237. The IBM AS/400 TCP/ IP Guide
| (SC41-9875) contains an example program for checking FTP return code s in the
| FTP output file.
| In addition a sample REXX procedure and a sample physical file membe r for
| batch FTP are shipped as part of the TCP/IP product. The IBM AS/400 TCP/IP
| Guide (SC41-9875) explains how to use this program.
-- ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 210.78.138.104]
|
|