Christopher_Mal
ServiceNow Employee
Options
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
09-10-2012
03:24 PM
There is a concept of executing command line (DOS and shell) scripts on the MID server (triggered by something on the instance server). I got sick of inserting the ECC queue record every time I wanted to run a command, so i created a script include that does it all for you.
Install this update set (attached to this blog). It is an update set with only one Script Include called CommandProbeES. You can call it from any business rule, UI Action, or other script in the following way:
var commandprobe = new CommandProbeES("YOUR_MIDSERVER_NAME");
commandprobe.setCommand("dir"); // you can put ls -l here or ipconfig - your command goes here depending on OS mid server is running on.
commandprobe.create();
The above usage puts a record in the ECC queue table and will get a return input with the following XML
<result command="dir">
<stdout>
Volume in drive C is OS Volume Serial Number is 2C1A-1398 Directory of C:\ServiceNow\MID Server1\mid.2012-07-18-1833.windows.x86-32\agent 09/10/2012 12:26 PM <DIR> . 09/10/2012 12:26 PM <DIR> .. 09/10/2012 12:25 PM <DIR> bin 09/10/2012 12:25 PM <DIR> conf 09/10/2012 12:29 PM 5,776 config.xml 09/10/2012 12:25 PM <DIR> etc 09/10/2012 12:29 PM <DIR> extlib 09/10/2012 12:25 PM <DIR> jre 09/10/2012 12:26 PM <DIR> lib 09/10/2012 12:29 PM <DIR> logs 09/10/2012 12:25 PM <DIR> package 09/10/2012 12:25 PM <DIR> properties 09/10/2012 12:25 PM 17 start.bat 09/10/2012 12:25 PM 16 stop.bat 09/10/2012 12:29 PM <DIR> work 3 File(s) 5,809 bytes 12 Dir(s) 714,052,411,392 bytes free
</stdout>
<stderr/>
</result>
You can also call any batch process or executable this way as well.
4 Comments
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.