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

Exec a "MV" (move) Linux command from ABAP program using wildcard "*"

Former Member
0 Likes
3,913

Hi,

I have a problem by using FM "SXPG_COMMAND_EXECUTE", SM49 while i try to move the whole content of a SAP folder into another.

Foders are on the same file system:

source: /tmp/

dest: /usr/sap/tmp

I made a command in SM69 named ZMOVE:

I put OS: Linux (is case sensitive)

command: "mv"

parameters: /tmp/* /usr/sap/tmp

hence the final sentence should be "mv /tmp/* /usr/sap/tmp". I did it directly by using program "rsbdcos0" and works fine.

Now if I try to execute the command ZMOVE from SM49 or using the function module it gives the same error

*mv: cannot stat /tmp/ ': No such file or directory**

I made several tries by changing the parameter section (also using a script on the same directory).

The permissions are ok, so the only problem seems to be the wildcard (*) character.

Any suggestions?

Thanks in advance

Fabrizio

2 REPLIES 2
Read only

Former Member
0 Likes
1,832

Problem solved.

Forget function modules, SM69 etc. there's an ABAP command in order to perform a SO command.

Here an example:

data: lf_file like rlgrap-filename,

lf_idx(3) type n,

cmd(254),

result(255) occurs 100 with header line.

cmd = 'mv /dir_source/* /dir_dest'.

call 'SYSTEM' id 'COMMAND' field cmd

id 'TAB' field result-sys.

Read only

0 Likes
1,832

Thanks for sharing, I was running into the same problem some time ago (with SunOS, not Linux though). The only downside is that this requires a small custom ABAP program, as opposed to a simple job step directly for the external command.

It is still a mystery to me why the external command works for moving single files, but not for multiple files via wildcards.

Thomas