Thisexampleshowshow toretrievefilesfromseveralremotehoststoa centralsysteminbatchmode.
UserGWILonSYSNAM03wantsto dothefollowingsteps: 1. Retrieve filesfromhostsSYSNAMRS(RS/6000
®)andMVAX(VAX).
2. AfterretrievingthefilefromSYSNAMRS,transferthefiletoSYSNAM02(anothersystem)usingFTP.
3. From SYSNAM02,send thefiletoSYSNAM14usingTCP/IP.
Example:CreatingaCLprogramtostartFTP:
ThisisanexampleCLprogramtostart FileTransferProtocol(FTP)inbatchmode.TheCLprogram containscommandstooverridethecommandinputandmessageoutput,starttheFTP,anddeletethe overrideswhentheFTPisclosed.
1. Asshown inthesimpleexample,FTPusesthedisplaystationforcommandINPUT andmessage
OUTPUT, andthisneedstobeoverriddenforuseinbatchmode.Inthisexample,theOVRDBF commandisusedtooverwritethesefileswith theonestobeusedinbatch:
OVRDBF FILE(INPUT) TOFILE(GERRYLIB/QCLSRC) MBR(FTPCMDS)
OVRDBF FILE(OUTPUT) TOFILE(GERRYLIB/QCLSRC) MBR(FTPLOG)
2. AhostnameoranInternet addressisarequiredparameterfortheSTRTCPFTPcommandthatis
includedintheCLprogramfile.However, ifyouwanttospecifytheremotesystemsintheinput commandsfileinsteadoftheCLprogramfile,youmust specifya dummyhostnamefor the
STRTCPFTPcommandtosatisfytherequiredsyntax.Thisdummynamecanbea fictitioushostname orarealhostname.Ifitisarealname,then thefirstentryintheinputcommandsfilemustbea user IDanda password,and thesecondentrymust betheCLOSEsubcommand.Ifitisnota realhost name,theseentriesarenotrequired,andthefirstentrymust beanOPEN subcommandtoconnectto therequiredFTPserver.
FTP RMTSYS(LOOPBACK)
FTPprocessestheinputfileandwrites messagestotheoutputfile(FTPLOG). 3. AftertheFTPapplicationends, deletetheoverrides:
DLTOVR FILE(INPUT OUTPUT)
TheCLprogramfor batchFTPwilllooklikethefollowingexample,inFigure1,onsystem SYSNAM01:
Note: Byusingthecodeexamples,youagreeto thetermsofthe“Codelicenseanddisclaimer
information”onpage158.
Example:CreatingtheFTP inputfile(FTCPDMS):
TheFTPinputfilemustcontainalltheFTPclient subcommandsnecessarytoconnectandlogontothe FTPserver,setupandcompletethefiletransfers,closetheconnection,and endtheclientsession. This exampleshowsthesubcommandsusedfortransferringfilestotwodifferentremotesystems.
Note: By usingthecodeexamples, youagreetothetermsofthe“Codelicenseand disclaimer
information” onpage158. Columns . . . : 1 71 Browse GERRYLIB/QCLSRC SEU==> FTPBATCH FMT ** ...+... 1...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ***************Beginning of data ************************************* 0001.00 PGM
0002.00 OVRDBF FILE(INPUT) TOFILE(GERRYLIB/QCLSRC) + 0003.00 MBR(FTPCMDS)
0004.00 OVRDBF FILE(OUTPUT) TOFILE(GERRYLIB/QCLSRC) + 0005.00 MBR(FTPLOG)
0006.00 FTP RMTSYS(LOOPBACK) /* (FTP CL Program) */ 0007.00 DLTOVR FILE(INPUT OUTPUT)
0008.00 ENDPGM
******************End of data ****************************************
F3=Exit
F5=Refresh F9=Retrieve F10=Cursor F12=Cance
F16=Repeat find F24=More keys
(C) COPYRIGHT IBM CORP. 1981, 1994.
ThefollowingexplanationcanhelpyoutounderstandtheFTPclientsubcommandsshown inFigure2. Thelinenumbersonthedisplaycorrespondtothenumbersthatfollow.
0001 UserIDand passwordfordummyconnectionwithin clientsystemSYSNAM03.
0002 ClosedummyconnectiononsystemSYSNAM03.
0003 OpencontrolconnectiontoRISCSystem/6000® SYSNAMRS.
0004 USERsubcommandwith userIDandpasswordforSYSNAMRS.
Note: WhenrunningFTPinbatchmode,theUSERsubcommand mustfollowanOPENsubcommand.
BoththelogonuserIDandpasswordparametersfortheUSERsubcommandshouldbe provided. ThisisdifferentwhenoperatingFTPinteractivelyonline.WhenFTPisruninteractivelyonline, and thentheclientwillautomaticallyinitiatea USERsubcommand andpromptyoufora logon ID. ThereisnoautomaticUSERsubcommandwhenrunningFTPinbatchmode.
0005 TransferASCII data(willbe convertedonthesystem to/fromEBCDIC).
0006 CLcommandtobe runontheclientsystemtodeletethefile.(Youcould insteadusethe REPLACEparameter withthenextstatement, theget.)
0007 RetrievefilefromRISCSystem/6000system.
0008 ClosecontrolconnectiontoRISCSystem/6000SYSNAMRS.
0009 OpenconnectiontoVAXMVAX.
0010 USERsubcommandwith userIDandpasswordforMVAX.
0011 RetrievefilefromVAXreplacingexistingi5/OSfile.
0012 ClosecontrolconnectiontoVAXMVAX.
0013 Opencontrolconnectiontoremotesystem SYSNAM02.
0014 USERsubcommandwith userIDandpasswordforSYSNAM02.
Columns . . .: 1 71 Browse GERRYLIB/QCLSRC SEU==> FTPCMDS FMT ** ...+...1 ...+... 2 ...+... 3 ...+... 4 ...+... 5...+... 6 ...+... 7 ***************Beginning of data************************************* 0001.00 gwil **** 0002.00 close 0003.00 open sysnamrs 0004.00 user rootroot 0005.00 ascii
0006.00 syscmddltf file(gerrylib/rs6) 0007.00 get /Itsotestgerrylib/rs6.rs6 0008.00 close
0009.00 open mvax
0010.00 user testertester
0011.00 get screen1.filegerrylib/vax.vax (replace 0012.00 close
0013.00 open sysnam02 0014.00 user gwil**** 0015.00 ebcdic
0016.00 put gerrylib/rs6.rs6gerrylib/rs6.rs6
0017.00 quote rcmdsndnetf file(gerrylib/rs6) tousrid((gwilsysnam14)) 0018.00 close
0019.00 quit
******************End of data****************************************
F3=Exit F5=Refresh F9=Retrieve F10=Cursor F12=Cancel
F16=Repeat find F24=More keys
Figure2.Transferringfilestotworemotesystems
| |
0015 TransferEBCDICdata(asitisfromaSystemiplatformtoa Systemiplatform).
0016 Sendi5/OSfilestosystem SYSNAM02with TCP/IP.
0017 SendthisfilefromsystemSYSNAM03toremotesystemSYSNAM14through TCP/IPnetwork.
0018 ClosecontrolconnectiontosystemSYSNAM02.
0019 EndFTPapplication.
Example:CLprogramforsubmittingtheFTPBATCHjob:
Toschedulethefiletransfersandruntheminunattended mode,createa CLprogramthatsubmitsthe FTPBATCHjob.Inthisexample,thefiletransfersaretorunthenextFriday,17:00hour, inunattended mode.
Note: By usingthecodeexamples, youagreetothetermsofthe“Codelicenseand disclaimer
information” onpage158.
Example:CheckingtheFTPoutputfileforerrors:
Whilerunningatthescheduledtime,FTPcreates datainfilememberFTPLOG.Thedatainfilemember FTPLOGcorrespondstooriginalstatementsfoundinbothexamples.Checktheoutput(FTPLOG)for errorsthatmighthaveoccurredduring theFTPprocessing.
Hereisanexampleoftheoutputfile:
Note: By usingthecodeexamples, youagreetothetermsofthe“Codelicenseand disclaimer
information” onpage158.
Columns . . . : 1 71 Browse GERRYLIB/QCLSRC
SEU==> FTPSUBMIT FMT ** ...+... 1...+... 2 ...+... 3 ...+... 4 ...+... 5...+... 6 ...+... 7 ***************Beginning of data************************************* 0001.00 PGM 0002.00 SBMJOB CMD(CALLPGM(GERRYLIB/FTPBATCH)) + 0003.00 JOB(FTPFRIDAY)OUTQ(QUSRSYS/GERRYQ) + 0004.00 SCDDATE(*FRI)SCDTIME(170000) /* FTP for + 0005.00 Friday, 5:00 in theafternoon */ 0006.00 ENDPGM ******************End of data**************************************** F3=Exit
F5=Refresh F9=Retrieve F10=Cursor F12=Cancel
F16=Repeat find F24=More keys
(C) COPYRIGHT IBMCORP. 1981, 1994.
Connectingto host name LOOPBACK at address 127.0.0.1using port 21.
220-QTCP at localhost.
220 Connectionwill close if idle more than 5 minutes.
Enter login ID(gwil):
>>>GWIL ****
331 Enter password.
230 GWIL loggedon.
i5/OS is theremote operating system. The TCP/IP versionis "V4R2M0".
250 Now usingnaming format "0".
257 "QGPL" iscurrent library.
Enter an FTPsubcommand.
> CLOSE
221 QUIT subcommandreceived.
Enter an FTPsubcommand.
> OPEN SYSNAMRS
Connecting tohost name SYSNAMRS at address 9.4.73.198 usingport 21.
220 sysnamrs.sysnam123.ibm.comFTP server (Version 4.9 ThuSep 2 20:35:07 CDT
1993) ready.
Enter an FTPsubcommand.
Figure4.FTPoutput(FTPLOG)afterrunningFTPBATCHprogram(Part1of5)
> USER root ****
331 Passwordrequired for root.
230 User rootlogged in.
UNIX Type: L8Version: BSD-44
Enter an FTPsubcommand.
> ASCII
200 Type setto A; form set to N.
Enter an FTPsubcommand.
> SYSCMD DLTFFILE(GERRYLIB/RS6)
Enter an FTPsubcommand.
> GET /ItsotestGERRYLIB/RS6/RS7
200 PORT commandsuccessful.
150 Opening dataconnection for /Itsotest (467 bytes).
226 Transfercomplete.
467 bytes transferredin 2.845 seconds. Transfer rate 0.167KB/sec.
Enter an FTPsubcommand.
| > CLOSE 221 Goodbye. Enter an FTP subcommand. > OPEN MVAX
Connecting to hostsystem mvax at address 9.4.6.252 usingport 21.
220 FTP ServiceReady
Enter an FTP subcommand.
> USER TESTER ******
331 User name TESTERreceived, please send password
230 TESTER loggedin, directory $DISK1:[TESTER]
Enter an FTP subcommand.
GET SCREEN1.FILEGERRYLIB/VAX.VAX (REPLACE
200 PORT CommandOK.
125 ASCII transferstarted for $DISK1:[TESTERSCREEN1.FILE;1(266586 bytes)
226 File transfercompleted ok.
265037 bytes transferredin 8.635 seconds. Transfer rate30.694 KB/sec.
Enter an FTP subcommand. > CLOSE 221 Goodbye. Enter an FTP subcommand. OPEN SYSNAM02
Connecting to hostsystem SYSNAM02 at address 9.4.73.250using port 21.
220-QTCP at SYSNAM02.sysnam123.ibm.com.
220 Connection willclose if idle more than 5 minutes.
Enter anFTP subcommand.
Figure6.FTPoutput(FTPLOG)afterrunningFTPBATCHprogram(Part3of5)
|
> USER GWIL ****
331 Enter password.
230 GWIL loggedon.
i5/OS is the remoteoperating system. The TCP/IP version is "V4R2M0".
250 Now using namingformat "0".
257 "QGPL" is currentlibrary.
Enter an FTP subcommand.
> EBCDIC
200 Representationtype is EBCDIC nonprint.
Enter an FTP subcommand.
> PUT GERRYLIB/RS6.RS6GERRYLIB/RS6.RS6
200 PORT subcommandrequest successful.
150 Sending fileto member RS6 in file RS6 in library GERRYLIB.
250 File transfercompleted successfully.
467 bytes transferredin 0.148 seconds. Transfer rate 3.146 KB/sec.
Enter an FTP subcommand.
> RCMD SNDNETF FILE(GERRYLIB/RS6)TOUSRID((GERRYLIB SYSNAM14))
250 Command SNDNETFFILE(GERRYLIB/RS6) TOUSRID((GWIL SYSNAM14))
successful.
Enter an FTP subcommand.
Youcaneither checkvisuallyorruna programthattestsforerrorreplycodes. Three-digitFTPerror replycodes startwith 4or5.Be carefultoavoidmessages,suchas’467bytestransferred...’.
Sampleprocedure:AsampleREXXprocedureanda samplephysicalfilememberareshippedaspartofthe TCP/IPproduct. FileQATMPINCinlibraryQTCPincludesthefollowingtwomembers:
v BATCHFTPthatcontainsREXXsourcecode tospecifytheinputandoutputbatchfiles,and startFTP.
v BFTPFILEthatcontains thesubcommandsanddatarequiredforlogonand runningFTP.