superk Advanced

Joined: 19 Dec 2002 Posts: 684 Topics: 5
|
Posted: Fri Nov 11, 2005 10:43 am Post subject: Using REXX TCP/IP Sockets to FTP file to a remote server. |
|
|
I am writing a Rexx utility for our automation system that uses TCP/IP sockets to transfer a dataset from the z/OS server to a remote FTP server.
Everything is working OK so far, but I do have a problem determing the proper sequence of commands to actually transfer the data.
According to the standards, the PORT command must be issued before the STOR command. According to the standards, the format of the PORT command is:
PORT a1,a2,a3,a4,p1,p2
where a1,a2,a3,a4 is the IP address, and p1,p2 is the port. What I can't determine is how to calculate the p1,p2 values. What do they represent?
Also, does just sending the STOR command initiate the data transfer, or does the process require a SEND command also to actually transfer the datastream?
Here's what I have so far:
Code: |
/* REXX */
ftp_server = 'xx.TTT.x.TTT'
crlf = x2c('0d25')
str = Socket('initialize', Date(B))
Parse Var str sockrc subtaskid maxdesc tcpipuser
str = Socket('Socket', 'af_inet', 'stream', 'tcp')
Parse Var str sockrc sockid
str = Socket('SetSockOpt', sockid, 'sol_socket', 'SO_ASCII', 'on')
server_info = 'AF_INET 21 ' || ftp_server
str = Socket('Connect', sockid, server_info)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length ftp_response
Say ftp_response
msg = 'USER userid' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length ftp_response
Say ftp_response
msg = 'PASS password' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length ftp_response
Say ftp_response
msg = 'TYPE A' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length ftp_response
Say ftp_response
msg = 'CWD temp' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length ftp_response
Say ftp_response
msg = 'PORT a1,a2,a3,a4,p1,p2' || crlf
str = Socket('Send', sockid, msg)
msg = 'STOR test.txt' || crlf
str = Socket('Send', sockid, msg)
str = Socket('Recv', sockid, 10000)
Parse Var str sockrc data_length ftp_response
Say sockid ftp_response
msg = 'QUIT' || crlf
str = Socket('Send', sockid, msg)
Say 'Send:'str
str = socket('Close', sockid)
Say 'Close:'str
str = socket('Terminate', subtaskid)
Say 'Terminate:'str
Exit
|
|
|