Forum Stats

  • 3,875,897 Users
  • 2,266,986 Discussions
  • 7,912,374 Comments

Discussions

Run python script from bash script not works in AIX when it is executed from Oracle Forms 12c

User_G4WFE
User_G4WFE Member Posts: 16 Green Ribbon

Hi everyone

Environment:

1 ) I have AIX 7

2 ) over this AIX I have installe Oracle forms 12.2.1

3 ) this AIX have korn shell

4) Installed python version is 2.7

4 ) ERP clients use windows 10 to run ERP application

5 ) command which python show: /usr/bin/python

6 ) python --version show: Python 2.7.18

Then, I need run python script from Oracle App from client. I am using HOST command.

Bash script works ok if I run this bash from AIX terminal... but if run it from ERP client using command host, bash commands works ok but python script called from inside bash script not works.

Simple example:

-- test.sh

#!/bin/bash

echo " start bash " && /u02/oraApp12c/transfer/test.py

echo " after executing py script"

-- test.py

#!/usr/bin/python

with open('test.txt', 'w') as f:

f.write('test test test\n')

Both scripts have all permissions (chmod a+x) and located in /usr/oraApp12c/transfer. This directory is accessible...

Running from terminal like this $ ./text.sh works ok (file test.txt is created).... BUT if I call test.sh from WHEN-BUTTON-PRESSED in my form file test.txt not created, the part /u02/oraApp12c/transfer/test.py sees not executed ( in fact is not executed )


In my form I am executing:

.....

......

Lv_command := '/u02/oraApp12c/transfer/test.sh';

HOST(LV_command)

....

.....

I searched in google and seems python evironment is not loaded/recognized when call python from bash....

I have tried call python script directly from oracle forms when-button-pressed but not works too.

I have also tried locate like first line into python script : #!/usr/bin/python2.7 but not works

I have also tried locate like first line into python script : #!/usr/bin/env python2.7 but not works

I have also tried locate like first line into python script : #!/usr/bin/env python but not works


Summary: Python script called from bash script not works if bash script is called from oracle forms when-button-pressed BUT it works OK if it is executed from AIX terminal


Thanks in advanced.

Answers

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 7,493 Employee

    If you expect to execute the code on the user machine you will need to WebUtil enable your form then use CLIENT_HOST.

    If you are expecting to execute on the server, update the Forms environment configuration (e.g. default.env) to include the PATH to python.

    More information about WebUtil can be found in the Builder Help


    Michael Ferrante

    Senior Principal Product Manager

    Oracle

    Twitter: @OracleFormsPM

  • User_G4WFE
    User_G4WFE Member Posts: 16 Green Ribbon

    Good Morning averyone

    Please Michael.. tell me with more datails your solution.

    My default.env was changed to add python path installation.. but yet not works.

    The modification is this :

    LIBPATH=/u01/app/oracle/product/......:/usr/bin/python2.7

    I'm using HOST command in oracle forms because I need to execute python sentences from server..

    I have searched on google about this theme but without success..


    Thanks in advance.

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 7,493 Employee

    Not LIBPATH. PATH needs to be updated. It should only include the directory path to the location of the executable. The value should not include the executable name itself.


    Michael Ferrante

    Senior Principal Product Manager

    Oracle

    Twitter: @OracleFormsPM