Faryal
Faryal

Reputation: 55

Oracle ODI || OSCommand || Rename Files

I am working in Oracle ODI 11g. I have linux source server. I have to rename all files in a folder by removing prefix (e_). I used the command:

     cd /weblogic/
     for f in $(ls e*); do echo mv "${f}" "${f##e_}"; done

via putty and it was working fine. This command does not work in OSCommand API of ODI. I get following exception:

   java.io.IOException: Cannot run program "for": error=2, No such file or directory   

Adding quotes around the command does not solve the issue. I have also tried to copy this command in test.sh file but it does not execute from ODI OSCommand as well. (which is executing from putty as well). The permission of file was set to 777. I get following exception

    java.io.IOException: Cannot run program "./weblogic/test.sh": error=2, No such file or directory

I can rename single file in directory from ODI but it does not work with "for". Can anyone help me in executing this command from ODI? or is there any workaround for this prblem?

Upvotes: 0

Views: 6600

Answers (1)

Faryal
Faryal

Reputation: 55

I found the solution myself.

1) I was using OSCommand and commands were not recognized. I have used ODIOSCommand and it worked fine.

2) I was specifying bash shell command and it was throwing exception

   syntax error at line 1: `$'

According to documentation, http://gerardnico.com/doc/odi/webhelp/en/ref_tools/snpsoscommand.htm , ODI supports POSIX-compliant OS's, using "sh". I have used

    cd #V_SRC_BB_LOCAL_DIR ; for f in e_* ; do mv "$f" "`echo $f | sed -e 's/^e_//'`" ; done

#V_SRC_BB_LOCAL_DIR is global variable containing the directory of files.

Please note renaming files in directory in ODI is only an example. If only renaming files in directory is required, it can be done by ODIFileMove in package.

Upvotes: 2

Related Questions