cancel
Showing results for 
Search instead for 
Did you mean: 

EXEC function in BODS - Unable to execute shell script

Former Member
0 Kudos

Hi All,

I'm trying to execute a script from the exec() in BODS job as below

exec('/opt/bodsxfer/testftp.sh','',8);

The testftp.sh is a script created to ftp the file to a different server from BODS server. Below is the content in the file

#!/usr/bin/expect -f

HOST='10.xxx.xxx.xx'

USER='xxx'

PASSWD='xxx'

ftp -n -v $HOST <<END_SCRIPT

user $USER $PASSWD

cd /applic/pcenter/trigger_files/

put BODS.txt

quit

END_SCRIPT

exit 0

The job says it ran successfully but the file is not ftp 'ed to the other server. I can run the above script from putty and ftp the file but not from BODS.

Anybody had this issue before?

Please help.

Thanks,

Rohith

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thanks Dirk & Satya for your inputs!

I tried the below script and its working

exec('sh', '/opt/bodsxfer/testftp.sh',8).

The only thing that bothers me here is the BODS.txt file that i'm trying to ftp needs to be placed in the LINK_DIR.(/opt/bods/dataservices/bin).

If i place the file in /opt/bodsxfer/ i'm getting an error "No such file or directory".

Do i need to place the file only in link_dir? What needs to be done to place the file else where on the BODS server?

Thanks,

Rohith

former_member187605
Active Contributor
0 Kudos

That's because /opt/bods/dataservices/bin is your HOME directory.

It will work if you change your script to:

#!/usr/bin/expect -f

HOST='10.xxx.xxx.xx'

USER='xxx'

PASSWD='xxx'

ftp -n -v $HOST <<END_SCRIPT

user $USER $PASSWD

lcd /opt/bodsxfer/

cd /applic/pcenter/trigger_files/

put BODS.txt

quit

END_SCRIPT

exit 0

Former Member
0 Kudos

Thanks a lot Dirk! Its working now.

Answers (2)

Answers (2)

Former Member
0 Kudos

Rohith,

Your flag is set to 8 which means the error will be caught. printing the statement will give us a better idea of error.

print(exec('/opt/bodsxfer/testftp.sh','',8));

Execute the above script in BODS. It will print the error during execution in your trace log. You can proceed further as  per the error in trace log.

Thanks

Sameera.

former_member187605
Active Contributor
0 Kudos

The job says it ran successfully because your script explicitly returns 0.

Run it from the shell under the DS credentials to debug:

1/. the DS user has no read access to the file

2/. the source file is not in the home folder - either insert an lcd command before the put or specify the full path