HP ARPA File Transfer Protocol User's Guide (36957-90159)

Chapter 4 45
Using FTP
Using FTP Commands in UDCs and Programs
!EOJ
Programmatic Example
You 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.
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 Information
Use 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.
program ftp_prog (input, output);
Const
var
msglevel
cr
cmdimage
cmderror
parmnum
= 0
= chr (13);
: string [80]
: shortint;
: 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.