ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Retreiveing variable data from a third party

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

  • Retreiveing variable data from a third party

    Hi guys

    Now i want to get some data from a third partty into our as400 using sftp.

    filenames have some randam generated conventions ex :- satyaadsdmonthtime,satyaadsdmonthtime

    The bold part changes everytime

    Currently we do this by using the getting the generic part
    get satya*

    putting it into an ifs and using dsplnk to store it into a file(where we get the whole file name)

    then using the get command again this time get satyaadsdmonthtime we get the actual file

    Are there any other way we can acheive this ?

    the file name changes and thts my concern..

  • #2
    Re: Retreiveing variable data from a third party

    Are there other files in the directory that you don't want to get that prevents you from doing a Mget?
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: Retreiveing variable data from a third party

      Another way to do it is to list the directory to a file, then spin through that file and download the stuff that matches the pattern that you're looking for.

      Will that work for you?

      You haven't explained what's wrong with the solution you're already using, so it's hard to guess what alternative method might work better.

      Comment


      • #4
        Re: Retreiveing variable data from a third party

        Originally posted by Scott Klement View Post
        Another way to do it is to list the directory to a file, then spin through that file and download the stuff that matches the pattern that you're looking for.

        Will that work for you?

        You haven't explained what's wrong with the solution you're already using, so it's hard to guess what alternative method might work better.
        Hi scott, listing is just what i want to do but how i do list the third party directory files in an as400 file what command do i use.Also there are two files in the directory so listing should get all the file names in the as400 pf and i want one file at a time to process.

        The solution tht i am using now works fine and good just wanted to know a better way/alternative way of doing it (learning new code )

        Comment


        • #5
          Re: Retreiveing variable data from a third party

          Originally posted by DeadManWalks View Post
          Are there other files in the directory that you don't want to get that prevents you from doing a Mget?
          yes there are multiple files in the directory but i have never used mget though.

          Comment


          • #6
            Re: Retreiveing variable data from a third party

            look up
            ls (disk
            My system is down so...
            Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

            Comment


            • #7
              Re: Retreiveing variable data from a third party

              LS (DISK writes a listing of the remote directory to a file called LSOUTPUT in your *CURRENT library. From memory the filename cannot be changed, it is always LSOUTPUT.

              You can even do LS satya* (DISK

              If you want to send it to a specific work library then you need to change your *CURRENT library on the 400 before starting thr FTP to the remote server.
              Greg Craill: "Life's hard - Get a helmet !!"

              Comment


              • #8
                Re: Retreiveing variable data from a third party

                Guys, this is sftp. The 'mget' and 'ls (disk' syntax is for the IBM FTP client, not sftp.

                For sftp, just script the regular 'ls' command, and redirect the output to a file.

                Comment


                • #9
                  Re: Retreiveing variable data from a third party

                  Originally posted by satya View Post
                  yes there are multiple files in the directory but i have never used mget though.
                  Hi Satya.

                  I don't know if you ever solved this issue but it is easy to do with ARP-SFTP. You can do a list command in the script and GET the files by using a RTVLSTE command. It's easy, self-cleaning and can be processed in 1 CL script. You can download ARP-SFTP at www.arpeggiosoftware.com/arpsftp. I have pasted the CL pgm you could use to do it (just have to change the server names and directories to your settings). In this example I am retrieving to one local file and adding to it but you can easily write to different files or different members or however you wish to set it up.

                  Hope that helps.

                  Best Regards,
                  Richard


                  PGM

                  /* This variable is used to trap error conditions. */
                  DCL VAR(&IN99) TYPE(*LGL)
                  DCL VAR(&FILE) TYPE(*CHAR) LEN(80)

                  /* Use a lazy global monitor message. */
                  MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))
                  MONMSG MSGID(UFT0000) EXEC(GOTO CMDLBL(ERROR))

                  STARTSSN:
                  /* Start an FTP session to */
                  AFSTRFTP SVRDFN(SFTPUBUNTU)
                  /* If no session established... */
                  MONMSG MSGID(UFT9800 UFT9100) EXEC(DO)
                  SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Error +
                  connecting to server') TOPGMQ(*PRV) +
                  MSGTYPE(*DIAG)
                  GOTO CMDLBL(ERROR)
                  ENDDO

                  SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
                  MSGDTA('Connected to server and logged +
                  in') TOPGMQ(*PRV) MSGTYPE(*DIAG)

                  /* Change directories. */
                  AFCHDIR DIRECT(getdir)
                  /* List files in directory */
                  AFLIST PATH(A*) OUTPUT(*RTVCMD)
                  MONMSG MSGID(UFT9800) EXEC(DO)
                  SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('No +
                  files to get') TOPGMQ(*PRV) MSGTYPE(*DIAG)
                  GOTO CMDLBL(NOFILES)
                  ENDDO

                  GETNEXT:
                  /* Retrieve file name from list command to GET */
                  AFRTVLE LISTENTRY(&FILE)
                  MONMSG MSGID(UFT9800) EXEC(DO)
                  SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('no more +
                  files to get') TOPGMQ(*PRV) MSGTYPE(*DIAG)
                  GOTO CMDLBL(NOFILES)
                  ENDDO

                  AFGETDBF RMTPATH(&FILE) TOFILE(RICH/MYFILE) +
                  OVERWRITE(*ADD)
                  /* GET command returned error */
                  MONMSG MSGID(UFT9800) EXEC(DO)
                  SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Error +
                  getting file.') TOPGMQ(*PRV) MSGTYPE(*DIAG)
                  GOTO CMDLBL(ERROR)
                  ENDDO

                  GOTO CMDLBL(GETNEXT)

                  NOFILES:
                  /* Script completed normally */
                  SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
                  MSGDTA('ARP-SFTP Script completed +
                  normally') TOPGMQ(*PRV) MSGTYPE(*DIAG)

                  ENDSSN:
                  AFENDFTP
                  MONMSG MSGID(UFT9800)
                  /* Finished. */
                  FINISHED:
                  RETURN
                  ERROR:
                  /* Error loop safety indicator */
                  IF COND(&IN99 *EQ '1') THEN(RETURN)
                  CHGVAR VAR(&IN99) VALUE('1')
                  SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
                  MSGDTA('ARP-SFTP Script ended in error') +
                  TOPGMQ(*PRV) MSGTYPE(*DIAG)
                  GOTO CMDLBL(ENDSSN)

                  ENDPGM

                  Comment


                  • #10
                    Re: Retreiveing variable data from a third party

                    Why do you have to have the second 'get' - didn't you get it with the first one? If not use mget

                    Comment

                    Working...
                    X