ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SFTP Automatic Process

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

  • SFTP Automatic Process

    Hello,

    I need help, I been out of the AS400 for more than 10 years, and recently I been asked to change our current FTP to a SFTP. I did the FTP through a CL program, but I have no idea how to do a SFTP the same way.
    If anybody can help me step by step how to do it, my life will be saved

    Thank you.

  • #2
    Re: SFTP Automatic Process

    Not sure if you're considering a commercial solution, but we use Arpeggio's AR-SFTP software. Reasonably priced, and works very well. Makes setup of new connections, file transfers from CL programs from/to either the IFS or QSYS file systems a cinch.

    Cheers,

    Emmanuel

    Comment


    • #3
      Re: SFTP Automatic Process

      check http://www-01.ibm.com/support/docvie...d=nas8N1012709
      and this http://www-01.ibm.com/support/docvie...d=nas8N1012710

      and this is what i do in my CL;

      Code:
                  PGM        PARM(&sFTPUser       +                            
                                  &sFTPSite       +                            
                                  &SubmitFlag     +                            
                                  &Link           )                            
                                                                               
      ...
                                                                                  
                  /* if no records in table, then do nothing */                   
                  RtvMbrD    File(XXXXXX) NbrCurRcd(&Records)                  
                  IF         Cond(&Records *EQ 0) Then(Goto CmdLbl(END))          
                                                                                  
                                                                                  
                  IF         COND(&SubMitFlag *Eq 'Y') THEN(DO)                   
      
                     Chgvar   &SubMitFlgO  Value('N')                          
                     Chgvar   &SftpUserO   Value(&sFTPUser)                    
                     Chgvar   &SftpSiteO   Value(&sFTPSite)                    
                     Chgvar   &LinkO       Value(&link    )                    
                  SBMJOB     CMD(CALL PGM(XXXXXXXXJQ) PARM(&sFTPUserO      +   
                                                           &sFTPSiteO      +   
                                                           &SubmitFlgO     +   
                                                           &LinkO       )) +   
                             JOB(TRECS_TBD)                              +     
                             JOBD(JDAJOBD)                               +     
                             USER(&SFTPUSER)                             +     
                             INLLIBL(*JOBD)                                    
                                                                               
                                                                               
                     goto End                                                  
                  ENDDO                                                        
               
                  CHGVAR     VAR(&COMMAND) +                               
                               VALUE('/QOpenSys/usr/bin/sftp -vvv -b +     
                               /home/' *TCat &sFTPUser *TCat +             
                              '/Utility/put_tbd.txt ' || &slcFTPUser +     
                               *TCat '@' *TCat &sFTPSite *TCat +           
                               ' > /home/' *TCat &slcFTPUser *TCat +       
                               '/Utility/Put_tbd_Log.txt 2>&1')            
                                                                           
                  QSH        CMD(&Command)                                 
                                                                           
                  RCVMSG  MSGTYPE(*COMP) RMV(*NO) MSGDTA(&MSGDTA) +        
                          MSGID(&MSGID)                                    
                                                                                                
                  CHGVAR VAR(&RC) VALUE(0)                                                      
                  IF      COND(&MSGID *EQ 'QSH0005') THEN(CHGVAR +                              
                      VAR(&RC) VALUE(%BIN(&MSGDTA)))                                            
                  IF COND(&RC *NE 0) THEN(DO)                                                   
                     /* Error processing */                                                     
                     DlyJob 60                                                                  
                  CHGVAR     VAR(&SendFile) VALUE('/home/' *TCat +                              
                               &sftpUser *TCat '/Utility/put_tbd_log.txt')                      
                  MMAIL/emlhtml SUBJECT('sftp - XXXX Conection Issue: View Source to Read') +  
                               FROMNAME('ftp Errors') +                                         
                               FROMADDR(DONOTREPLY@XXX.CO+                     
                               M) TO(FTPISSUE@XXXX.COM/'ftp +                          
                               issue'/*TO) +                                                    
                               STMF(&SendFile) +                                                
                               IMPORTNC(*HIG) PRIORITY(*URG)                                    
                  ENDDO                                                                         
                                                                                                
                                                                                                
                  RmvLnk       Objlnk(&Link)                                                    
                              
                              
      END:         ENDPGM
      A few notes. Sftp must run under the same user profile as the Key you set up.
      The put_tbd.txt has the standard CD and put statements (or Get) as was built by a previous called program.

      This is not the entire code but should get you started.
      Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

      Comment

      Working...
      X