sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Thread Issue calling Python Program from CL from RPG using Scott Klement's UNIXCMD

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

  • Thread Issue calling Python Program from CL from RPG using Scott Klement's UNIXCMD

    Like many others (and for good reason) we're being pushed away (quickly) from FTP in favor of SFTP. Thank goodness for open source while I wait for a purchase req to be approved for some real software.

    I'm running into a problem though, that I only seem to be experiencing when calling from my RPG program and CL programs containing Mr. Klement's UNIXCMD calls. Traceback below. This problem does not occur if I call /SFTP/sftp-getter.py directly from a shell.

    Code:
    Traceback (most recent call last):
    File "/SFTP/sftp-getter.py", line 48, in <module>
    with pysftp.Connection(**cinfo) as sftp:
    File "/QOpenSys/pkgs/lib/python3.6/site-packages/pysftp/__init__.py", line
    self._transport.connect(**self._tconnect)
    File "/QOpenSys/pkgs/lib/python3.6/site-packages/paramiko/transport.py", l
    self.start_client()
    File "/QOpenSys/pkgs/lib/python3.6/site-packages/paramiko/transport.py", l
    self.start()
    File "/QOpenSys/pkgs/lib/python3.6/threading.py", line 846, in start
    _start_new_thread(self._bootstrap, ())
    RuntimeError: can't start new thread
    CPF9897 received by SFTPGETTE2 at 4300. (C D I R)
    The call to *LIBL/SFTPGETTE2 ended in error (C G D F)
    CL Program below:
    Code:
    PGM PARM(&HOST &USER &PASS &PORT &LDIR &DIR &FILE &REMOVE)
    DCL VAR(&REC)  TYPE(*CHAR) LEN(1000)                      
    DCL VAR(&EOF)  TYPE(*LGL)                                 
    DCL VAR(&HOST) TYPE(*CHAR) LEN(16)                        
    DCL VAR(&USER) TYPE(*CHAR) LEN(16)                        
    DCL VAR(&PASS) TYPE(*CHAR) LEN(16)                        
    DCL VAR(&PORT) TYPE(*CHAR) LEN(5)                         
    DCL VAR(&LDIR) TYPE(*CHAR) LEN(512)                       
    DCL VAR(&DIR)  TYPE(*CHAR) LEN(512)                       
    DCL VAR(&FILE) TYPE(*CHAR) LEN(128)                       
    DCL VAR(&REMOVE) TYPE(*CHAR) LEN(1)                       
    DCL VAR(&CMD) TYPE(*CHAR) LEN(500)                        
    CHGVAR VAR(&CMD) +                                        
         VALUE('PATH=/QOpenSys/pkgs/bin:$PATH; +              
               export PATH; +                                 
               python3 /SFTP/sftp-getter.py')                 
    
    /*DMPCLPGM*/                                              
    /*GOTO ENDPGM*/                                           
    ADDENVVAR ENVVAR(SSH_HOST) VALUE(&HOST) REPLACE(*YES)                     
    ADDENVVAR ENVVAR(SSH_USER) VALUE(&USER) REPLACE(*YES)                     
    ADDENVVAR ENVVAR(SSH_PASSWORD) VALUE(&PASS) REPLACE(*YES)                 
    ADDENVVAR ENVVAR(SSH_PORT) VALUE(&PORT) REPLACE(*YES)                     
    ADDENVVAR ENVVAR(SSH_DIR) VALUE(&DIR) REPLACE(*YES)                       
    ADDENVVAR ENVVAR(SSH_LDIR) VALUE(&LDIR) REPLACE(*YES)                     
    ADDENVVAR ENVVAR(SSH_FILE) VALUE(&FILE) REPLACE(*YES)                     
    ADDENVVAR ENVVAR(SSH_REMOVE) VALUE(&REMOVE) REPLACE(*YES)                 
    
    ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE('FILE=/TMP/SFTP-GETTER.LOG') +
         REPLACE(*YES)
    ADDENVVAR ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) VALUE(Y) REPLACE(*YES)
    
    OPNPIPE CMD(&CMD) TYPE(*PASE)                                   
    
    RCVPIPE RCD(&REC) EOF(&EOF)                                     
    
    DOWHILE (&EOF *EQ '0')                                          
          SNDUSRMSG MSG(&REC)                                        
          RCVPIPE RCD(&REC) EOF(&EOF)                                                
    ENDDO                                                                           
    
    CLOPIPE                                                                         
    
    MONMSG MSGID(QSH0000) EXEC(DO)                                                  
         SNDMSG MSG('FILE TRANSFER FAILED! SEE /TMP/SFTP-GETTER.LOG') TOUSR(QSYSOPR)
    ENDDO                                                                           
    ENDPGM:                                                                         
    ENDPGM

  • #2
    The error seems to indicate that Python can't start a new thread. Have you made sure your environment is set up for multi-thjreaded applications?

    Can you explain why you are using Python? Your message says you need sftp. This does not require Python.

    Comment

    sponsored links

    Collapse

    Working...
    X