cancel
Showing results for 
Search instead for 
Did you mean: 

Calling UNIX commands in BODS SCRIPT

Former Member
0 Kudos

Hi,

I have a scenario, where I have the input in Filename.txt

S|ABC|GB

S|ABC|TS

Output should be like

'GB','TS'

So,I written following UNIX command to get the above output;

grep "S|ABC" Filename.txt | cut -d'|' -f3 | xargs | sed "s/[^ ][^ ]*/'&',/g" | sed 's/,$//'

I want to call the above command in BODS SCRIPT. Is it can be accomplished?

Kindly show me some light on it.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member198401
Active Contributor
0 Kudos

Data Services cannot send commands to Unix OS but it can only send to Database tables.

former_member187605
Active Contributor
0 Kudos

Use exec built-in function.

From the SAP Data Services Reference Guide:

exec(<command_file, parameter_list, flag>)

with <command_file>:

A string that indicates the location and file name to execute. This string is relative to the Job Server location. It can be an absolute or relative path. The files and directories in the path must be accessible from the Job Server's computer.

The <command_file> can be a Windows batch file, a UNIX shell script, or a binary executable. To run other interpreted scripts, the <command_file> must be the name of the command interpreter (e.g., 'perl') and the script must be the first parameter in the <parameter_list> .

former_member198401
Active Contributor
0 Kudos

Thanks for reminding me Dirk !! I just missed the exec() function or just went out of my mind

Answers (1)

Answers (1)

former_member198401
Active Contributor
0 Kudos

Just put your command in the script file

grep "S|ABC" /usr/folder_name/Filename.txt | cut -d'|' -f3 | xargs | sed "s/[^ ][^ ]*/'&',/g" | sed 's/,$//'

First of all the BODS user account which is running the job should have permissions to execute the script(bash or KSH script).

Just took an example

$File_Availability=exec('ksh','[$$Scriptfilepath]/Unix_file_check.ksh',8);

where $$Scriptfilepath= absolute path to the script file

Regards

Arun Sasi

former_member198401
Active Contributor
0 Kudos

Please close this thread if your issue is resolved