ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

QMGTOOLS/STRSFTP - how to use parameters

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

  • QMGTOOLS/STRSFTP - how to use parameters

    Hi,
    I'm about to use QMGTOOLS/STRSFTP for different purposes as regular ftp transfer should be replaced.

    Qualified file transfer with parameter FUNCTION(*PUT) and FUNCTION(*GET) was an easy task and can also be called within a CL... BUT

    - I should send multiple files with generic file names (e.g. all files put_file* from IFS directory IFS/Temp/ to sFTP directory ReceiveData/ )
    - I should get multiple files with generic file names (e.g. all files get_file* from SFTP directory SendData/ to IFS directory IFS/Temp/)
    - I should rename files on the SFTP Server (e.g. putting a file sent_file.tmp and then rename to sent_file.dat)
    - I shuold move file(s) on the SFTP server after getting the file(s) from a diretory to another one (e.g. after getting file(s) from SFTP directory ReceiveData/ moving to ReceiveData/Archive/

    All the above mentioned actions I think should be possible to perform by using the Parameter FUNCTION(*CMD) and with the command line - bot how?

    Any idea how these transfers can be done? Thanks a lot

    Regards,
    Stephan

  • #2
    Hi,
    I got my problem resolved - thanks to my RPG-buddy!
    FUNTION(*CMD) is used to handle this pretty well with the command line for e.g. RMTCMD('mget /sFTPdirectory/SendData/get_file*.* /IFSdirectory/Temp/')

    Only the verification of success or not is still a bit doutful as the log file e.g. LOGDIR('IFS/MyLog.txt') ist not very easy to decipher.

    Thank you any way!

    Regards,
    Stephan

    Comment


    • #3
      I was wondering if you could share more detailed information on how you solved the problem of sending (MPUT) multiple files. I'm in the same situation with a very short timeframe. I really don't want to have to initiate a new session for each file to be transmitted, but it's looking like I might have to.

      Comment


      • #4
        Hi,

        this is my approach of using MPUT

        Feel free to use the variables as CL Input parameters (or create a command) to perform the transfer.
        For generic file sending it is usual to use an asterix (*) sign but better do not use it for logging purpose.

        Note:
        Generally system setting uses port 22
        Parameter RMTCMD is limited to 132 characters

        DCL VAR(&IFS_PATH) TYPE(*CHAR) LEN(100)
        DCL VAR(&SFTP_PATH) TYPE(*CHAR) LEN(100)
        DCL VAR(&TRANSFILE) TYPE(*CHAR) LEN(100)
        DCL VAR(&LNKNAME) TYPE(*CHAR) LEN(100)
        DCL VAR(&RMT_CMD) TYPE(*CHAR) LEN(132) /* max 132 char */
        DCL VAR(&X_RMT) TYPE(*CHAR) LEN(30)
        DCL VAR(&X_USR) TYPE(*CHAR) LEN(30)
        DCL VAR(&X_PWD) TYPE(*CHAR) LEN(30)

        DCL VAR(&FILE_GENE) TYPE(*CHAR) LEN(100)
        DCL VAR(&LOG_DIR) TYPE(*CHAR) LEN(80)
        DCL VAR(&LOG_FIL) TYPE(*CHAR) LEN(80)
        DCL VAR(&LOG_MPUT) TYPE(*CHAR) LEN(9) +
        VALUE('.MPUT.txt')

        CHGVAR VAR(&X_RMT) VALUE('sftp.server.name')
        CHGVAR VAR(&X_USR) VALUE('user')
        CHGVAR VAR(&X_PWD) VALUE('password')
        CHGVAR VAR(&TRANSFILE) VALUE('MyFile*')
        CHGVAR VAR(&FILE_GENE) VALUE('MyFile_genereic')
        CHGVAR VAR(&IFS_PATH) VALUE('/IFS/Temp/')
        CHGVAR VAR(&SFTP_PATH) VALUE('/Path_sFTP/')
        CHGVAR VAR(&LOG_DIR) VALUE('/IFS/Temp/')

        /* sFTP command */
        CHGVAR VAR(&LOG_FIL) VALUE('Log_' *CAT &FILE_GENE +
        *TCAT &LOG_MPUT)
        CHGVAR VAR(&LNKNAME) VALUE(&LOG_DIR *TCAT &LOG_FIL)
        DEL OBJLNK(&LNKNAME)
        MONMSG MSGID(CPF0000)
        CHGVAR VAR(&RMT_CMD) VALUE('MPUT ' *CAT &IFS_PATH +
        *TCAT &TRANSFILE *TCAT ' ' *CAT &SFTP_PATH)
        QMGTOOLS/STRSFTP CONFIG(*NOCFG) +
        RMTLOC(&X_RMT) +
        USR(&X_USR) +
        PWD(&X_PWD) +
        FUNCTION(*CMD) RMTCMD(&RMT_CMD) +
        KEEPLOG(Y) LOGDIR(&LOG_DIR) LOGFILE(&LOG_FIL)


        I am rather using RMTCMD with 'PUT' instead of 'MPUT'.
        The reason is that I can better control the transfer and its completion by checking the logfile.
        Doing so I have implemented an error messaging after each file transfer.

        Regards,
        Stephan

        Comment


        • #5
          This is perfect ! Thank you so much. You have saved me hours and hours of trial and error !

          Regards,
          Sandy

          Comment

          Working...
          X