/* REXX */ /* example of z/OS FTPAPI */ /* prompts for hostname, userid and password */ /* then accepts FTP commands; quit to exit */ /* establish environment */ ftp_rc = FtpApi('fcai.', 'create', 'TID') if (ftp_rc < 0) then Do Call signerr cmd,ftp_rc Exit 8 End /* establish session */ Say 'Enter hostname:' Pull hostname ftp_rc = FtpApi('fcai.', 'init', '-w 300 '||hostname) if (ftp_rc < 0) then Do Call signerr cmd,ftp_rc Exit 8 End ftp_rc = FtpApi('fcai.', 'getl_copy', 'lines.', 'A') Do i = 1 to lines.0 Say lines.i End i /* send userid & password */ Say 'Enter userid:' Parse Pull uid Say 'Enter password:' Parse Pull pass Command = 'USER 'uid Call sendcmd command Command = 'PASS 'pass Call sendcmd command /* process command input */ Do while command \= 'QUIT' Say 'Enter FTP command or QUIT:' Parse Pull command If command = 'quit' then command = 'QUIT' Call sendcmd command End /* terminate */ ftp_rc = FtpApi('fcai.', 'term') Exit 0 sendcmd: Procedure Expose fcai. /* send an FTP command */ Parse Arg cmd ftp_rc = FtpApi('fcai.', 'scmd', cmd, 'W') if (ftp_rc < 0) then, Call signerr cmd,ftp_rc Else , Say ' Result =' fcai.FCAI_Result' Reply =' fcai.FCAI_ReplyCode ftp_rc = FtpApi('fcai.', 'getl_copy', 'reply.', 'A') Do i = 1 to reply.0 Say reply.i End i Return signerr: Procedure Expose fcai. /* report an error */ Parse Arg cmd,cmd_rc If Left(cmd,5) = 'PASS ' then , cmd = 'PASS ********' Say 'A bad thing happened for 'cmd', RC='cmd_rc say ' Result =' fcai.FCAI_Result , ' Reply =' fcai.FCAI_ReplyCode say ' RC =' fcai.FCAI_ReturnCode , ' Reason =' fcai.FCAI_ReasonCode say ' Status =' fcai.FCAI_Status Return