MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using REXX TCP/IP Sockets to FTP file to a remote server.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Fri Nov 11, 2005 10:43 am    Post subject: Using REXX TCP/IP Sockets to FTP file to a remote server. Reply with quote

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 
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Nov 11, 2005 11:04 am    Post subject: Reply with quote

Superk,

check and see if these links are of any use !

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/EZ306700/3.2.2?DT=19950622202951

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/EZ306700/4.5?DT=19950622202951

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group