cancel
Showing results for 
Search instead for 
Did you mean: 

How to Run Operating System Command Before/After Message Processing SAP PI

Former Member
0 Kudos

Hi,

We are trying to execute multiple commands via "Operating System Command Before/After Message Processing".

When we use single command say for example cp or mv (copy or move) the commands get executed fine.

eg: cp %F /var/opt/data/outbound/Test/Dummy.txt

/this works fine/

when we club commands together or try to redirect the outputs of commands, none of the commands get executed.

eg:

cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F

or

wc -l %F > /var/opt/data/outbound/Test/Dummy.txt

Is it possible to execute multiple commands or redirect the output of commands without using a shell script? The PI server we are working on iis hosted on UNIX environment.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

have you tried putting all the commands you need inside a script, such as .bat (for MS Win Operating system) or .sh (for *nix Operating Systems)?

Under Unix, you could use something like this, inside script.sh:

#!/bin/sh

cp $1 /var/opt/data/outbound/Test/Dummy.txt

rm $1

wc -l $1 > /var/opt/data/outbound/Test/Dummy.txt

in the Operating System Line, you will call the script as /<yourWorkingDirectory>/script.sh %F

Hope this help!

Regards,

Antonio

former_member187339
Active Contributor
0 Kudos

Hi Harleen,

try like this

cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F

instead of semicolon try this


(1) & 
 command1 & command2 
 Execute Command1 and then execute Command2
 
(2) && 
 command1 && command2
 Runs the command2 only when command1 doesn't Complete successfully
 
(3) || 
 command1 || command2
 Runs the second command if the first command had an error
 
(4) () 
 (command1 || command2) || (command3 & command4) 
 Defines the order in which commands are to be executed

Regards

Suraj

Former Member
0 Kudos

Hi Suraj,

thanks for replying. I tried using '&' but still facing the same issue.

Standalone both these commands work:

cp %F /var/opt/data/outbound/Test/Dummy.txt

mv %F /var/opt/data/outbound/Test/Dummy.txt

but when i try combining them, the command simply stops working.

cp %F /var/opt/data/outbound/Test/Dummy.txt & mv %F /var/opt/data/outbound/Test/Dummy.txt

I tried redirecting the output to a log file, to see if there were any errors encountered. But re-direction also doesn't seem to be working.

Former Member
0 Kudos

Hi Harleen,

Include all ur command in one file and call that file in the OS parameter.