z/OS Communications Server: IP User's Guide and Commands
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Issuing FTP subcommands from a file

z/OS Communications Server: IP User's Guide and Commands
SC27-3662-00

Figure 1 is an example of an EXEC that issues FTP subcommands from a data set. In this example, the FTPIN1 data set is used for the FTP subcommands, and FTPOUT1 is used to store the FTP session dialog. This example must be invoked from TSO.
Figure 1. How to issue the FTP subcommands from a data set
/*REXX*/
"ALLOC DA(FTPIN1) DD(INPUT) SHR REU"   /* Input will be from FTPIN1 */
if rc ¬= 0 then do
   say 'Error in ALLOC INPUT, rc = ' rc
   exit
end
"ALLOC DA(FTPOUT1) DD(OUTPUT) SHR REU" /* Output goes to FTPOUT1     */
if rc ¬= 0 then do
   say 'Error in ALLOC OUTPUT, rc = ' rc
   exit
end
"FTP YKTVSH"                          /* FTP to the YKTVSH host       */
"FREE DD(INPUT)"
"FREE DD(OUTPUT)"
EXIT
Figure 2 is an example of an EXEC that issues FTP subcommands from a z/OS® UNIX file. In this example, the name of the input file and output file are passed as arguments on the EXEC. For example,
EXAMPLE1 /u/user117/ftpin1  /u/user117/ftpout1
where EXAMPLE1 is the name of the EXEC. This example must be invoked from the z/OS UNIX shell.
Figure 2. How to issue the FTP subcommands from a z/OS UNIX file system
/* rexx                                                                    */
/*                                                                         */
/* Input: infile - z/OS UNIX file containing FTP commands                  */
/*        outfile - z/OS UNIX file to contain FTP output. If not specified */
/*                  output goes to terminal.                               */
 
parse arg infile outfile .          /* get command line input        */
 
if infile = '' then                 /* input file not specified      */
  do
    say 'Input file name is required.'
    exit 12                         /* return to UNIX System Services */
  end
else
  input_file = '<' infile           /* redirect input from file   */
 
if outfile <> '' then
  output_file = '>' outfile         /* redirect output to file       */
else
  output_file = ''
 
address syscall "stat (infile) fstat."  /* test if input file exist  */
if fstat.0 = 0 then                 /* input file not found          */
  do
    say 'Input file:' infile 'not found.'
    exit 28                         /* return to UNIX System Services */
  end
 
"ftp -v -p TCPIP" input_file output_file  /* invoke FTP client with
                                       input and output redirection  */
 
say "FTP client return code is:" rc  /* print client return code     */
 
exit 0                              /* return to UNIX System Services */

The following is an example of the input file (either the input data set FTPIN1 or the z/OS UNIX file /u/user117/ftpin1).

krasik mvsftp
cd examples
put t.info t1.info
get t1.info t2.info (r
quit
Where:
krasik
Is the user ID
mvsftp
Is the password
t.info
Is the file to be transferred

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2013
This information center is Built on Eclipse™ ( www.eclipse.org ).