cancel
Showing results for 
Search instead for 
Did you mean: 

Reg. sapcontrol's OSExecute function

Former Member
0 Kudos

Hi All,

We're planning to use "OSExecute" function and try to run some commands on SAP system.

The "OSExecute" function seems to execute the command successfully, but output of the command which was executed is not displayed correctly.

Here is the OSExecute command and output:

********

[root@AAA ~]# pwd

/root

[root@AAA ~]# /usr/sap/hostctrl/exe/sapcontrol -nr 00 -function OSExecute "pwd" 0 30

09.09.2014 23:49:07

OSExecute

OK

exitcode, pid, lines

2, 52098

[root@AAA ~]#

***********

Looking at the above command output:

1) I was thinking the "lines" column should display the output of the pwd command, which is "/root". But, "/root" is not dispalyed in command output.  Not sure why?

2) I couldn't find in the SAP document(/internet) what the "exitcode" 2 indicates.

3) I believe this is not related to user privileges.

The issue seems to be only with "OSExecute" function of sapcontrol.

As an additional information, we're able to execute other functions of "sapcontrol". Please find the below command output:

*****

# /usr/sap/hostctrl/exe/sapcontrol -nr 00 -function GetProcessList

09.09.2014 23:30:57

GetProcessList

OK

name, description, dispstatus, textstatus, starttime, elapsedtime, pid

msg_server, MessageServer, GREEN, Running, 2014 09 08 23:41:27, 23:49:30, 28473

igswd_mt, IGS Watchdog, GREEN, Running, 2014 09 08 23:41:27, 23:49:30, 28475

disp+work, Dispatcher, GREEN, Running, Message Server connection ok, Dialog Queue time: 0.00 sec, 2014 09 08 23:41:27, 23:49:30, 28474

[root@AAA ~]#

*********

If you've any idea on "OSExecute" function , please let me know. Greatly appreciated.

Thanks,

Mahesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try to provide full path to the command.

Former Member
0 Kudos

I have used the full command path only:


/usr/sap/hostctrl/exe/sapcontrol -nr 00 -function OSExecute "pwd" 0 30

Former Member
0 Kudos

I mean full path to the command you are trying to execute with OSExecute function. In your case:


sapcontrol -nr 00 -function OSExecute "/bin/pwd" 0 30

Former Member
0 Kudos

Thank you, Roman. That works.

Answers (2)

Answers (2)

v_veeramalla
Active Participant
0 Kudos

please check the document @ http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60e24f7b-1ba1-2b10-c0a0-e514b8556...

OSExecute <command> <async> <timeout> <protocolfile>

divyanshu_srivastava3
Active Contributor
0 Kudos

Hi Mahesh,

Try to add "service/protectedwebmethods = NONE OSExecute" or "service/protectedwebmethods = DEFAULT OSExecute" in instance profile and try again with sidadm and other users.

Regards,

Divyanshu

Former Member
0 Kudos

Hi Divyanshu,

thanks for quick response.

I have updated the profile file as you suggested , but no luck.

Please find the below command and output.

******service/protectedwebmethods = NONE OSExecute**************

SIDadm> /usr/sap/hostctrl/exe/sapcontrol -nr 00 -function RestartSystem

10.09.2014 02:01:14

RestartSystem

OK

SIDadm> /usr/sap/hostctrl/exe/sapcontrol -nr 00 -function OSExecute "ls" 0 30

10.09.2014 02:01:30

OSExecute

OK

exitcode, pid, lines

2, 7638

SIDadm> cat /sapmnt/SID/profile/DEFAULT.PFL | grep service/protectedwebmethod

service/protectedwebmethods = NONE OSExecute

#service/protectedwebmethods = DEFAULT+OSExecute

***********************

*****service/protectedwebmethods = DEFAULT OSExecute **************

SIDadm> /usr/sap/hostctrl/exe/sapcontrol -nr 00 -function RestartSystem

10.09.2014 02:14:02

RestartSystem

OK

SIDadm> cat /sapmnt/SID/profile/DEFAULT.PFL | grep service/protectedwebmethod

service/protectedwebmethods = DEFAULT OSExecute

#service/protectedwebmethods = DEFAULT+OSExecute

SIDadm> /usr/sap/hostctrl/exe/sapcontrol -nr 00 -function OSExecute "pwd" 0 30

10.09.2014 02:14:36

OSExecute

OK

exitcode, pid, lines

2, 10309

SIDadm> /usr/sap/hostctrl/exe/sapcontrol -nr 00 -function OSExecute "ls" 0 30

10.09.2014 02:14:55

OSExecute

OK

exitcode, pid, lines

2, 10493

*******************

-Mahesh

divyanshu_srivastava3
Active Contributor
0 Kudos

Hi Mahesh,

BTW, I have missed the + sign.

Former Member
0 Kudos

Hi Divyanshu,

I have tried with '+' sign too. No luck.

-Mahesh

divyanshu_srivastava3
Active Contributor
0 Kudos

I have not used it before, but try this.

sapcontrol -nr 00 -function OSExecute command='pwd' async=0 timeout=30 protocolfile=””

sapcontrol -nr 00 -function OSExecute 'pwd' 0 30

Regards,

Former Member
0 Kudos

we have tried this , but no luck .

also, we found this error code "2" indicates:

2  StartWait, StopWait, WaitforStarted, WaitforStopped, RestartServiceWait

       timed out