This discussion is archived
4 Replies Latest reply: Jan 27, 2013 7:20 AM by user12236189 RSS

unix file server command and Jython error

user12236189 Newbie
Currently Being Moderated
Hello all,

For windows with local agent I am using this following
cmd /c dir c:\my_directory\*.* /b /a:-d > c:\my_directory\All_Files_Names.txt
what is the sequence of commands will be replaced for the above in UNIX server files

thanks,
  • 1. Re: unix file server command
    JeromeFr Expert
    Currently Being Moderated
    Hi,


    You can use
    ls -1 /home/your_user/my_directory/ > /home/your_user/my_directory/All_Files_Names.txt
    You might have to embed it into a sh script : Re: Extract the Files names Procedure for Linux????


    Hope it helps.

    Regards,
    JeromeFr
  • 2. Re: unix file server command
    user12236189 Newbie
    Currently Being Moderated
    Thank you Jerome.

    I am using as following command ODI procedure
    ls -1 /n01/app/oracle/product/odi/files/*tracking.csv > /n01/app/oracle/product/odi/files/All_Files_Names.txt
    And still getting the error as follows with Wrong process return code: 2
    ODI-1226: Step ALL_FILES_SERVER fails after 1 attempt(s).
    ODI-1232: Procedure ALL_FILES_SERVER execution fails.
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlS.getExceptionOnStepTaskFailure(SnpSessTaskSqlS.java:57)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatStepTaskError(SnpSessStep.java:1101)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:575)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:464)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2093)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
         at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
         at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
         at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
         at java.lang.Thread.run(Thread.java:662)
    and you link is also so useful and is that possible that without creating any scripts in server, can I achieve through ODI.

    I have tested with local agent with windows and it's working ok

    Only with linux server I am not able to get pass this error

    any help would be greatly appreciated.

    Thanks
  • 3. Re: unix file server command
    JeromeFr Expert
    Currently Being Moderated
    I really think you should create a script for this command.


    create a file get_cvs_files.sh and copy/paste the following content :
    #!/bin/sh
    ls -1 /n01/app/oracle/product/odi/files/*tracking.csv > /n01/app/oracle/product/odi/files/All_Files_Names.txt
    Then run
    chmod +x get_cvs_files.sh
    to allow execution.
  • 4. Re: unix file server command and Jython error
    user12236189 Newbie
    Currently Being Moderated
    SOLVED USING Guru Sankar's response from Print messages using Java or Jython

    I am trying with Jython as follows but still getting an error
    */n01/app/oracle/product/odi/files/* this folder has some other folders as well as some other files, all I need is *.csv* files from this folder */n01/app/oracle/product/odi/files/* is that possible for which I can get only *.csv* files through this script.
    import java.lang as lang
    import java.sql as sql
    import snpsftp
    import java.lang.String
    import java.io.File as File
    import ftplib
    import re
    import os
    
    #db connection
    driverSrc = 'oracle.jdbc.driver.OracleDriver'
    
    lang.Class.forName(driverSrc)
    
    urlSrc = 'jdbc:oracle:thin:@dwdb:1521:dev'
    userSrc = 'DWBI'
    passwdSrc = 'oracle'
    ConSrc = sql.DriverManager.getConnection(urlSrc, userSrc, passwdSrc);
    readDBLink = ConSrc.createStatement()
    
    try:
    # f=open('/n01/app/oracle/product/odi/files/All_Files_Names.txt','w+')
    list = os.listdir('/n01/app/oracle/product/odi/files/')
    for fichier in list:
    # str = java.lang.String(fichier)
    # f.write(fichier)
    sqlDBLink = "insert into DWBI.FILENAMES (LOADFILE) values ('" + fichier + "')"
    rqteDBLink = readDBLink.execute(sqlDBLink)
    
    finally:
    ConSrc.close()
    # f.close()
    But I am getting this error
    ODI-1226: Step STARJNEW fails after 1 attempt(s).
    ODI-1232: Procedure STARJNEW execution fails.
    Caused By: org.apache.bsf.BSFException: exception from Jython:
    SyntaxError: ("mismatched input 'list' expecting INDENT", ('<string>', 23, 0, "list = os.listdir('/n01/app/oracle/product/odi/files/')\n"))
    
         at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
         at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.execInBSFEngine(SnpScriptingInterpretor.java:322)
         at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.exec(SnpScriptingInterpretor.java:170)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java:2472)
         at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:47)
         at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:1)
         at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:558)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:464)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2093)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
         at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
         at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
         at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
         at java.lang.Thread.run(Thread.java:662)
    Caused by: SyntaxError: ("mismatched input 'list' expecting INDENT", ('<string>', 23, 0, "list = os.listdir('/n01/app/oracle/product/odi/files/')\n"))
    
         at org.python.core.PyException.fillInStackTrace(PyException.java:70)
         at java.lang.Throwable.<init>(Throwable.java:181)
         at java.lang.Exception.<init>(Exception.java:29)
         at java.lang.RuntimeException.<init>(RuntimeException.java:32)
         at org.python.core.PyException.<init>(PyException.java:46)
         at org.python.core.PyException.<init>(PyException.java:43)
         at org.python.core.PyException.<init>(PyException.java:39)
         at org.python.core.PySyntaxError.<init>(PySyntaxError.java:22)
         at org.python.core.ParserFacade.fixParseError(ParserFacade.java:96)
         at org.python.core.ParserFacade.parse(ParserFacade.java:203)
         at org.python.core.Py.compile_flags(Py.java:1685)
         at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:172)
         at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:144)
         ... 19 more
    Any help would be greatly appreciated.

    Thanks,

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points