Information

This site will undergo a brief period of maintenance on Friday, 18 December at 12:30 AM Central/12:00 PM IST. During a 30 minute window, site availability may be intermittent.

Executing scripts and commands on NSH


The following table describes the adapter request elements for executing scripts and commands on NSH.

Adapter request elements for executing scripts and commands on NSH

Element

Description

Required

<command>

Specifies the command or script name along with any required arguments that you want to execute on NSH ; contains the script-directory attribute to specify the directory path containing the script files. You can use this attribute to override the <script-directory> element in the adapter configuration. To execute any command on NSH, you must leave this attribute empty.

For example,
<command script-directory="">

Yes

The following code sample shows a sample adapter request for executing scripts and commands on NSH:

<bladelogic-request>
 <request-data>
  <command executable-type="nsh" timeout-secs="60">
   <command>nsh_script1.nsh</command>
  </command>
  <command executable-type="nsh" timeout-secs="60">
   <command script-directory="C:\Scripts\">nsh_script2.nsh</command>
  </command>
   <command executable-type="nsh" timeout-secs="60">
    <command script-directory="">hostname</command>
  </command>
 </request-data>
</bladelogic-request>

 

The following code sample shows the adapter response for script and command execution on NSH:

 <bladelogic-response>
 <metadata>
  <status>success</status>
 </metadata>
 <targets-output>
  <target-output>
   <metadata>
    <os-id>Windows 2003</os-id>
    <os-version>5.2</os-version>
    <os-arch>x86</os-arch>
    <status>success</status>
   </metadata>
  <commands-output>
   <command-output>
     <metadata>
      <command>/C/BladeLogic/8.0/jy_Scripts/nsh_script1.nsh</command>
      <line-count>9</line-count>
      <execution-milliseconds>406</execution-milliseconds>
      <exit-code>0</exit-code>
       <status>success</status>
     </metadata>
    <output>
      <line index="1">s-17125:</line>
      <line index="2">  Agent Release   : 7.4.3.1011</line>
      <line index="3">  Hostname        : S-17125</line>
      <line index="4">  Operating System: WindowsNT 5.2</line>-
      <line index="5">  User Permissions: BLRD@BMC1->Anonymous:PrivilegeMapped (Identity via trust)</line>
      <line index="6">  Security        : Protocol=5, Encryption=TLS1</line>
      <line index="7">  Host ID         : D45412A6</line>
      <line index="8">  # of Processors : 1</line>
      <line index="9">  License Status  : Licensed for NSH/CM</line>
    </output>
   </command-output>
   <command-output>
    <metadata>
     <command>/C/Scripts/nsh_script2.nsh</command>
     <line-count>3</line-count>
     <execution-milliseconds>42125</execution-milliseconds>
     <exit-code>0</exit-code>
     <status>success</status>
    </metadata>
    <output>
     <line index="1">/cygdrive/c/WINDOWS/system32</line>
     <line index="2">nsh:cd:2: connection timed out:</line>
     <line index="3">/cygdrive/c/WINDOWS/system32</line>
    </output>
   </command-output>
   <command-output>
    <metadata>
     <command>hostname</command>
     <line-count>1</line-count>
     <execution-milliseconds>188</execution-milliseconds>
     <exit-code>0</exit-code>
     <status>success</status>
    </metadata>
    <output>
     <line index="1">global-rbsjn05o</line>
    </output>
   </command-output>
  </commands-output>
 </target-output>
 </targets-output>
</bladelogic-response>

The following code sample illustrates a sample adapter request for executing the agentinfo command on NSH:

<bladelogic-request>
<command executable-type="nsh" timeout-secs="300">
 <command script-directory="">agentinfo machine1</command>
</command>
</bladelogic-request>

 

The following code sample shows the adapter response for the agentinfo command execution on NSH.

<bladelogic-response>
 <metadata>
   <status>success</status>
 </metadata>
 <targets-output>
   <target-output>
     <metadata>
       <os-id>Linux</os-id>
       <os-version>2.6.9-67.ELsmp</os-version>
       <os-arch>i386</os-arch>
       <status>success</status>
     </metadata>
     <commands-output>
       <command-output>
         <metadata>
           <command>agentinfo machine1</command>
           <line-count>8</line-count>
           <execution-milliseconds>3429</execution-milliseconds>
           <exit-code>0</exit-code>
           <status>success</status>
         </metadata>
         <output>
           <line index="1">machine1:</line>
           <line index="2">  Agent Release   : 8.0.0.393</line>
           <line index="3">  Hostname        : PortQA1</line>
           <line index="4">  Operating System: WindowsNT 5.2</line>
           <line index="5">  User Permissions: BLRD@PORTQA1->Anonymous:PrivilegeMapped (Identity via trust)</line>
           <line index="6">  Security        : Protocol=5, Encryption=TLS1</line>
           <line index="7">  Host ID         : A0493522</line>
           <line index="8">  #</line>
         </output>
       </command-output>
     </commands-output>
   </target-output>
 </targets-output>
</bladelogic-response>

 

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC Atrium Orchestrator Content 20.15.02