cancel
Showing results for 
Search instead for 
Did you mean: 

CALL SYSTEM for UNIX Commands - CP vs MV

arminpohl-123
Explorer
0 Kudos

Hello,

I noticed when i run a copy using call system to my unix system - the call command waits to return until the transfer is complete but with a move it goes on to the next abap line and the transfer occurs in the background which is problematic 🙂

Here is my copy call...

CONCATENATE 'cp'
source_file
destination_file
'2>& 1'
INTO unix_cmd SEPARATED BY space.
TRANSLATE unix_cmd TO LOWER CASE.

CALL 'SYSTEM' ID 'COMMAND' FIELD unix_cmd
ID 'TAB' FIELD tabl-*sys*.

Here is my move...

CONCATENATE 'mv'
source_file
destination_file
'2>& 1'
INTO unix_cmd SEPARATED BY space.
TRANSLATE unix_cmd TO LOWER CASE.

CALL 'SYSTEM' ID 'COMMAND' FIELD unix_cmd
ID 'TAB' FIELD lv_fd .

any insight on to why copy command waits while move doesn't ?

thanks in advance !

Accepted Solutions (0)

Answers (1)

Answers (1)

Harald
Advisor
Advisor
0 Kudos

Hi Armin,
have you tried the same commands 'native' on the AIX operating system level ?
When you do a 'mv' of 2 files on the AIX OS level within the same file system, it does not really 'move' any data but just changes the file name - which happens nearly instantaneously.

When you do a 'mv' from one file system to another one, then data needs to be moved/copied and this takes much longer.
When you do a 'cp', there data needs to be copied and depending on the size of the file and speed of the underlying file system / storage subsystem, this can take some time.
best regards, Harald

arminpohl-123
Explorer
0 Kudos

correct - i have witnessed similar natively.

my main concern is why the call command for the copy waits on the call command step in the abap until transfer is complete but the move returns right away even though transfer continues in the background. I'd like the move to behave the same as the copy and wait until the transfer is complete so I can also get an accurate sy-subrc

Harald
Advisor
Advisor
0 Kudos

Are you sure that the move command is really doing some data movement in the background ? A 'mv' within the same the filesystem takes usually only a few milliseconds, so it may seem from ABAP that the move command returns immediately, while it has in fact completed all its work.
Have you tested this with a file that is moved between file systems ?