Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

FTP from CL program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • FTP from CL program

    Rpg program creates data file from within CL program. Want to FTP that data file from within the CL pgogram to my pc (As400 operating system v3.r2). Can this be done?

  • #2
    FTP from CL program

    It depends. Do you have TCP/IP configured and started on your AS/400? Dave

    Comment


    • #3
      FTP from CL program

      There's an FTPBATCH utility in the new redbook, "V4 TCP/IP for AS/400: More Cool Things Than Ever, SG24-5190-00". The hardcopy ships with a CD with sample programs, but you can also download the associated programs on the same page you can download the .PDF from. Click on the "Additional Material" link. I usually get an error with FTP links in IE, so I use Netscape or Opera (can install from a floppy!) for troublesome downloads. The FTP link includes directions to create library COOLRED. Start at: http://www.redbooks.ibm.com/abstracts/sg245190.html I haven't done much with it yet. The sample CL for testing FTPBATCH is: PGM DCL VAR(&TFR) TYPE(*CHAR) LEN(1) CHGCURLIB CURLIB(COOLRED) COOLRED/FTPBATCH RMTSYS('YOURSYS') + LCLFIL('hot.savf') RMTFIL('hot.savf') + FUNCTION(G) USR(PROFILE) PWD(PASSWORD) + CMD1('namefmt 1') CMD2('cd + coolred_1.lib') CMD3(BINARY) SUCCES(&TFR) SNDPGMMSG MSG('Transfer: ' *CAT &TFR) MSGTYPE(*COMP) ENDPGM The CL for FTPBATCH describes the parms as: /* Program parameters: */ /* */ /* &TGTSYS (in ) - Target system */ /* &LCLFIL (in ) - Local file name */ /* &RMTFIL (in ) - Remote file name */ /* &FUNCTION (in ) - Function to be executed */ /* values: 'P' = Put */ /* 'G' = Get */ /* &USR (in ) - User ID in remote system */ /* &PWD (in ) - Password in remote system */ /* &CMD1 (in ) - Optional FTP subcommand */ /* (Executed before transfer) */ /* &CMD2 (in ) - Optional FTP subcommand */ /* (Executed before transfer) */ /* &CMD3 (in ) - Optional FTP subcommand */ /* (Executed before transfer) */ /* &SUCCES (out) - Success indicator */ /* values: '0' = Transfer failed */ /* '1' = Transfer successful */ /* */ /* All work files are created into library QTEMP. */ /* */ /* Programs called: */ /* */ /* BLDFTP1R (ILE RPG) - Creates the FTP script */ /* for transfer */ /* CHKFTP1R (ILE RPG) - Checks the success of transfer */ /* by reading the FTP transfer log */ /* */ Hope this helps.

      Comment


      • #4
        FTP from CL program

        Yes, it is configured and started.

        Comment


        • #5
          FTP from CL program

          Lewis, Are you sure you have to ftp the file from the as/400 to your pc? I only ask because the problem becomes trivial if you can arrange to ftp from the pc to the as/400 and get the file you want. For example, if the file is generated at night, you can have the pc run a bat file when the user boots it in the morning. The bat file could ftp to the as/400 and retrieve the file. FTP'ing from your as/400 to your pc means you have to have two basic things: the pc must be running an ftp server (which is no problem if your pc is an nt workstation) and the as/400 must know the ip address of your pc. That last one is the tricky part. Most networks I come in contact with use DHCP, so the workstation ip addresses change from time to time. If you can get your administrator to set you up so your pc's ip address doesnt change (which can be done even if you are using DHCP), you are ready to go. Alex Garrison

          Comment


          • #6
            FTP from CL program

            Alex, Thanks, I appreciate the additional insight as to how I could possibly handle this situation. Let me review this suggestion with the other personell involved.

            Comment


            • #7
              FTP from CL program

              My colleagues and I are currently checking into the redbook as suggested. Will let you know what our final solution will be.

              Comment


              • #8
                FTP from CL program

                Hi There, I developed a number of utilities to FTP Files/Spoolfiles etc to PCs as it was a major requirement for users. Probably our most frequently used utilities on a base of 500 Users. Initially we had a command SHOWIP in MSDOS which the Users could find out the IP Address of their PC and key this in to the utility each time. This became a real pain when we moved to DNS and had different IP addresses each time a user signed on. Then I discovered the API QDCRDEVD through a friend. Through this API you can derive the IP Address of the current PC/Workstation. Below is the code of the program used to derive the IP Address it has a fifteen character parameter which is guess what !!!! *************** Beginning of data ************************************* PGM PARM(&IP) DCL VAR(&DEVD) TYPE(*CHAR) LEN(10) DCL VAR(&IP) TYPE(*CHAR) LEN(15) DCL VAR(&RECEIVER) TYPE(*CHAR) LEN(892) DCL VAR(&LENGTH) TYPE(*CHAR) LEN(4) DCL VAR(&ERRLENGTH) TYPE(*CHAR) LEN(4) RTVJOBA JOB(&DEVD) CHGVAR VAR(%BIN(&LENGTH)) VALUE(892) CHGVAR VAR(%BIN(&ERRLENGTH)) VALUE(0) CALL PGM(QDCRDEVD) PARM(&RECEIVER &LENGTH + DEVD0600 &DEVD &ERRLENGTH) CHGVAR VAR(&IP) VALUE(%SST(&RECEIVER 878 15)) ENDPGM ****************** End of data **************************************** Hope this is a help to everybody. There are also a number of articles in the Classics series (ANE and NetJava Pages) of the Midrange Site outlining what's required for writing FTP Applications. The utilities I developed use the techniques mentioned in the above articles. In addition I have developed front end AS/400 SAA Screens which allow the User to key in the File/Spoolfile to be downloaded, the target (IP Address) defaulted as above, the Server password, the destination path/directory. This in turn is edited into the Input Batch File by an RPG program. This file is a QTEMP QTXTSRC Member used by the FTP Command to drive the download. If anybody is interested in finding out more detail as to how this technique works drop me a line. The FTP Utilities I developed have evolved over a number of years, if anybody has any intresting techniques for converting packed data when downloading a Physical File I would be glad to hear of it. Regards, Michael (I'm from the West of Ireland, my friends call me Mick)

                Comment

                Working...
                X