Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

OS command chmod execution through ABAP issue

Former Member
0 Likes
2,115

Hi all

I have an OS command execution through ABAP issue.

I am trying to change the file permissions using os command chmod execution

using

call 'SYSTEM' id 'COMMAND' field .

My code goes like this .........

data :w_ospath like w_target,

lc_chmod like w_target.

data: begin of tabl occurs 500,

line(400),

end of tabl.

CONCATENATE w_target '/*.txt' into w_ospath.

CONCATENATE 'chmod 777 ' w_ospath

INTO lc_chmod SEPARATED BY space.

CALL 'SYSTEM' ID 'COMMAND' FIELD lc_chmod

id 'TAB' field tabl[].

But nothing happening and return code is sy-subrc=0.

Any help ?

Regards

sateesh

2 REPLIES 2
Read only

Former Member
0 Likes
1,331

Hi Sateesh,

Your syntax looks a bit off, I'd expect something like this:


call 'SYSTEM' id 'COMMAND' field LC_CHMOD id 'TAB' field TABL-*SYS*.  

For testing it might help to redirect the output (stdout, stderr and return code) of the command to a file to check later in AL11 the results (assuming that you don't sit next to the basis guy with access to the server and that the directory you're looking at is mapped in AL11). As far as I remember chmod does not return any output, so your internal table should be empty.

However, in general let me add some further comments. When running OS commands you should always check with a basis person who has access to the server to see if they execute the command if it's working. In theory you might be trying to change the access for files for which you (or to be more precise the OS user running the SAP system) has no access. So apart from return code 0, you're saying the file permissions don't change? Are you using a correct file path?

If the command returned a non-zero return code on OS level, but you don't see that, check OSS note [1155864 - Call 'SYSTEM' returns incorrect exit code on UNIX|https://service.sap.com/sap/support/notes/1328083], which might be applicable.

Your chmod permissions of 777 seems really odd, I know it's valid, but seems rather unusual for example to mark text files as executable (are you sure that this is what you want to be doing?)...

Also, I'd refrain from using an approach like call 'SYSTEM' id 'COMMAND' and instead first investigate usage of [external commands|http://help.sap.com/saphelp_nw70ehp2/helpdata/en/fa/0971e1543b11d1898e0000e8322d00/frameset.htm]. Be prepared to have some talk with your security folks, because in most cases the execution of system commands is locked down (for good reasons).

Cheers, harald

Read only

0 Likes
1,331

Hi Harald

Thanks for your reply.

In fact i have got limited access to our server operating system in order to check the file attributes.

I am able to change the file permissions with my OS login and my file path is correct.

But through ABAP i am not able change the attributes .

Regards

sateesh