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


Issuing FTP subcommands directly from the EXEC interface

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

Figure 1 is an example of how to issue FTP subcommands directly from a REXX EXEC. The REXX stack is used to hold the FTP subcommands. This example runs in both the TSO and z/OS UNIX environments.
Note: To use FTP in a z/OS UNIX environment, TSO users must be authorized users or have a default z/OS UNIX user ID.
Figure 1. How to issue FTP subcommands from an EXEC
  /* rexx */
  /* push commands on stack                                              */
  QUEUE "YKTVSH"                        /* server address                */
  QUEUE "krasik mvsftp"                 /* userid/password               */
  QUEUE "cd /tmp/examples/"
  QUEUE "put t.info t1.info"
  QUEUE "cd .."
  QUEUE "cd dummy"
  QUEUE "quit"
 
  cmdargs = "-v -p TCPIP"               /* set ftp client arguments      */
 
  parse source . . . . . . . . env .    /* check if running under        */
                                        /* UNIX System Services          */
                                        /* env='OpenMVS' if invoked from */
                                        /* UNIX System Services,         */
                                        /* otherwise env=''              */
 
  if env = "OpenMVS" then               /* running under                 */
                                        /* UNIX System Services          */
                                        /* invoke ftp client             */
     call bpxwunix 'ftp -v -p tcpip',stack
  else                                  /* running under TSO             */
     "FTP" cmdargs                      /* invoke ftp client             */
 
  say "FTP client return code is:" rc   /* print client return code      */
 
  exit 0                                /* return                        */
Note: If data set DUMMY does not exist, FTP exits with a return code.
Figure 2 is an example of how to call FTP from a TSO/E REXX EXEC and enable it to solicit its FTP subcommands interactively from the user's TSO terminal. This requires that TSO/E has prompting enabled.
Figure 2. How FTP subcommands can be solicited interactively from an EXEC
   /* rexx */                                                                
   newstack;                            /* set up a null stack for FTP*/
                                        /*  so as to not disturb any  */
                                        /*  commands currently stacked*/   
   save_rexx_prompt_state = prompt();   /* save REXX prompt state     */  
   temp = prompt('ON');                 /* set prompting on to enable */  
                                        /*  interactive retrieval of  */  
                                        /*  ftp commands running      */  
                                        /*  under TSO                 */  
   "FTP ( exit"                         /* invoke ftp client          */  
   save_rc = rc;                        /* save FTP return code       */  
   temp= prompt(save_rexx_prompt_state);/* restore prompt setting     */  
   delstack;                            /* delete null stack for FTP  */  
   return save_rc;                      /* return                     */
Tips:
  • You can call this EXEC from another TSO/E REXX EXEC by invoking this EXEC as a function call. For example, if this EXEC is named rexxftp, invoke it with the following call: return_code = rexxftp()
  • If commands are stacked for processing and the newstack and delstack statements are removed from the sample, FTP subcommands are retrieved and processed from the stack. If no QUIT command is processed, FTP obtains commands interactively until a QUIT command is received.
  • See the FTP Client API REXX function information in the z/OS Communications Server: IP Programmer's Guide and Reference for an alternate method of using REXX to invoke the FTP client.

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 ).