Forum Stats

  • 3,836,897 Users
  • 2,262,204 Discussions


Problem With UNIX command in ODI Environment.

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(
at com.sunopsis.dwg.codeinterpretor.k.a(
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting( at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execSrcScriptingOrders(
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(
at com.sunopsis.dwg.dbobj.SnpSessTaskSqlS.treatTaskTrt(
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(
at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand( at com.sunopsis.dwg.cmd.DwgCommandBase.execute(
at com.sunopsis.dwg.cmd.e.i(
at com.sunopsis.dwg.cmd.g.y(
at Source)


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

    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

  • 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

  • Cezar Santos
    Cezar Santos Member Posts: 1,901

    Send the return to a file and use the method described at to get the value...

    Does it help you?

    Cezar Santos
  • 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 ?


  • 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
This discussion has been closed.