8 Replies Latest reply: Feb 8, 2013 4:17 AM by user132819 RSS

    Reg : ODI Invocation

    user132819
      Hi All ,

      Can anyone help me on this


      Can we invoke PHP script in ODI ?

      Regards,
      Karthik
        • 1. Re: Reg : ODI Invocation
          SH
          You can run a php script using jython so yes it can be done from within ODI.
          • 2. Re: Reg : ODI Invocation
            user132819
            Hi ,

            Can you provide me a supporting doc on this if you have , as i cant able to invoke here

            Regards,
            Karthik
            • 3. Re: Reg : ODI Invocation
              JeromeFr
              You can also call it through command line : http://www.php.net/manual/en/features.commandline.php

              So you can call it through ODI.


              Hope it helps.

              Regards,
              JeromeFr
              • 4. Re: Reg : ODI Invocation
                user132819
                When i tried calling from Jython in ODI , it gave the below error

                com.sunopsis.tools.core.exception.SnpsSimpleMessageException: Error during task interpretation
                Task:1
                java.lang.Exception: BeanShell script error: Sourced file: inline evaluation of:
                ``php /*########################################################################## . . . ''
                : Typed variable declaration : Class: php not found in namespace : at Line: 1 : in file: inline evaluation of:
                ``php /*########################################################################## . . . '' : php
                BSF info: PHP at line: 0 column: columnNo

                     at com.sunopsis.dwg.codeinterpretor.a.a(a.java)

                     at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)

                     at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)

                     at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)

                     at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)

                     at com.sunopsis.dwg.cmd.e.i(e.java)

                     at com.sunopsis.dwg.cmd.g.y(g.java)

                     at com.sunopsis.dwg.cmd.e.run(e.java)

                     at java.lang.Thread.run(Unknown Source)

                Regards,
                Karthik
                • 5. Re: Reg : ODI Invocation
                  SH
                  How were you invoking it? Were you using os.system?
                  • 6. Re: Reg : ODI Invocation
                    user132819
                    In ODI , in designer window , under procedure , created a new procedure and in that procedure in command window i have pasted this PHP script and i have selected technology as Jython and executed .

                    Regards,
                    Karthik
                    • 7. Re: Reg : ODI Invocation
                      Bhabani Ranjan
                      select jython as technology and pass the php page. Here is sample code.

                      import subprocess

                      def php(script_path):
                      p = subprocess.Popen(['php', script_path], stdout=subprocess.PIPE)
                      result = p.communicate()[0]
                      return result

                      # YOUR CODE BELOW:
                      news_script_output = php("news-generator.php") # call the function here and the parameter is the php page
                      print news_script_output
                      • 8. Re: Reg : ODI Invocation
                        user132819
                        Hi ,

                        When we tried your way we are gettong error


                        err msg:

                        org.apache.bsf.BSFException: exception from Jython:
                        Traceback (innermost last):

                        (no code object) at line 0

                        SyntaxError: ('invalid syntax', ('<string>', 4, 1, "p = subprocess.Popen(['php', script_path], stdout=subprocess.PIPE)"))

                        and also clear us on below

                        what is meant by script_path in the code. and where should we give the path of the php file (ex : E:/../PHP).

                        Regards,
                        Karthik