Forum Stats

  • 3,836,897 Users
  • 2,262,204 Discussions
  • 7,900,138 Comments

Discussions

Problem With UNIX command in ODI Environment.

706375
706375 Member Posts: 10
edited Oct 22, 2009 1:10PM in Data Integrator
A procedure is used in our package which involves moving a file from a folder to another in a UNIX server.

The procedure uses an OS command - 'os.system' to execute unix command.
The unix command is a grep command which seems to work fine when executed alone.
But when this procedure is executed ,it fails.

The following code raises an error and the procedure fails.:

if os.system(cmd) <> 0:
raise "command fails","see agent output for details";

Whenever we are trying to reverse,we get "file not Found " error.

We tried to execute the jython code by placing the files in local directories. The same error appears both when the file is in local and when it is in a remote directory.

This is the error we get:

org.apache.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "<string>", line 20, in ?
HeaderCmd failed:: See agent output for details at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java) at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execSrcScriptingOrders(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSqlS.treatTaskTrt(SnpSessTaskSqlS.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.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)
Tagged:

Answers

  • 606607
    606607 Member Posts: 288
    edited Oct 8, 2009 8:19AM
    Hi,

    The unix command is a grep command which seems to work fine when executed alone. :-

    I guess you executed this from your Unix server , so it work fines.
    And when you are trying to execute outside from this (using ODI) , its failing , right ?

    Can you please check the permission settings for that script file (sh).
    Please try by giveing the full permission (specifically execution permission) for all users connecting from other machines.

    This can be one of the reason for the failure .
    please let me know if this is not working

    Regards,
    Rathish
  • MansaPro
    MansaPro Member Posts: 46 Blue Ribbon
    Hi ODI gurus,

    I am looking to return the output of OS command to a ODI variable. Is there any way I can do this?

    Need to to fetch first file from unix folder command is "ls | head -1" and store the returned file name to a ODI variable so that i can process that file inside ODI.

    Thanks in Advance

    Mano.
  • Cezar Santos
    Cezar Santos Member Posts: 1,901
    Hi,

    Send the return to a file and use the method described at http://odiexperts.com/?p=243 to get the value...

    Does it help you?


    Cezar Santos
    [www.odiexperts.com]
  • MansaPro
    MansaPro Member Posts: 46 Blue Ribbon
    Thanks Santos,

    It is really a great solution.

    If we have a generate a interim file to store the OS output then another approach would be through External table. But your solution looks simpler and better.

    Can we execute the OS command in a ODI function and return through function return patameter ?

    Thanks,

    Mano.
  • Cezar Santos
    Cezar Santos Member Posts: 1,901
    Yes, that is quite normal.... For instance to get a list of files from a directory.

    I this case the first command could be: dir *.* > files.txt

    And then use the technique to get each value.

    Make any sense?


    Cezar Santos
    [www.odiexperts.com]
This discussion has been closed.