HP ARPA File Transfer Protocol User's Guide
> Chapter 4 Using FTPUsing FTP Commands in UDCs and Programs |
||||||||||||||||||||||||||
|
Using EXITONERRORThe MPE/iX FTP command EXITONERROR allows you to turn on or off the capability to exit an FTP session if an error occurs. The last error and message are saved in CI variables. To show the errors, enter the following at the MPE/iX colon prompt: :SHOWVAR FTP@In the following example, EXITONERROR is activated. The second GET command generates an error because the file does not exist: ftp> EXITONERROR ExitOnError mode on. (FTPINFO 33) ftp> GET filex filey 200 PORT command okay. 150 Opening data connection for filey (123.50.42.32,50897) (320 bytes). 226 Transfer complete. 322 bytes received in 0.65 seconds: (4.25 Kbytes/second) ftp> GET filez 200 PORT command okay. 550 filez: No such file or directory. Data Transfer Request Failed. (FTPERR 13) END OF PROGRAM : :SHOWVAR ftp@ FTPLASTERR = -13 FTPXFERFILES = 0 FTPREQFILES = 0 FTPREPLACE = true FTPLASTREPLY = 550 filez: No such file or directory FTPLASTMSG = Data Transfer Request Failed. (FTPERR 13) :
Transferring Multiple FilesYou can create a command file to automatically copy a group of files from the remote system into your account as in the following example.
Using a JobstreamThe following example shows how to use a job file to automate the logon procedure and retrieve a file from a remote system. To execute a job, enter STREAM jobname at the MPE/iX prompt (:). !JOB FTPFILE,USERNAME.ACCT,PUB !RUN FTP.ARPA.SYS OPEN 123.50.42.32 USER remuser rempass PWD DIR* GET file1 QUIT !EOJ Programmatic ExampleYou can use FTP commands in programs using the HPCICOMMAND intrinsic, as in the following example. The input file containing the FTP commands, FTPIN, is listed following the program. program ftp_prog (input, output); Const msglevel = 0; cr = chr (13); var cmdimage : string [80]; cmderror : shortint; parmnum : shortint; procedure HPCICOMMAND; intrinsic; begin { ----------------------------------------------------- } { Run the User-FTP program using the FTPIN input file. } { The FTPOUT file will be created in the temporary space} { and will contain the output of the FTP session. } { ----------------------------------------------------- } cmdimage := 'RUN FTP.ARPA.SYS;STDIN=FTPIN;STDLIST=FTPOUT,NEW' + cr; HPCICOMMAND (cmdimage,cmderror,parmnum,msglevel); if cmderror <> 0 then begin writelin ( 'CMDERROR = ', cmderror:1 ); writelin ( 'PARMNUM = ', parmnum:1 ); end; end.The contents of the STDIN file FTPIN are listed below: OPEN 123.50.42.32 USER remuser rempass PWD DIR* GET file1 GET file2 GET file3 QUIT Obtaining Status InformationUse the STATUS command to obtain status information regarding the FTP client and server. The status information is useful for debugging purposes and for identifying the states and modes of the client and server peers. In the following example, both the client (abc.cup.hp.com) and server (katsu.cup.hp.com) are MPE/iX machines. ftp>status Connected to katsu.cup.hp.com (22.11.138.29). (FTPINFO 40) Using ASCII mode to transfer files. (FTPINFO 25) Verbose mode on. (FTPINFO 22) Debugging off (debug=0). (FTPINFO 23) ExitOnError mode off. (FTPINFO 34) Interactive mode on. (FTPINFO 41) Lower case off. (FTPINFO 44) Store unique mode off. (FTPINFO 51) Receive unique mode off. (FTPINFO 53) Command tracing off. (FTPINFO 55) Data tracing off. (FTPINFO 57) Connection time-out value set to 120 seconds. (FTPINFO 49) 211- katsu FTP server status Version A0007F06 Connected to abc.cup.hp.com (25.33.144.142) Logged in as ,MANAGER.SYS,PUB TYPE: ASCII FORMat: Non-print; STRUcture: File; transfer MODE: Stream No data connection. 211 End of status. ftp>
|