Could someone tell me how to properly use the "Execute Shell Command - Get Results to Variable" command? It seems very straight-forward, but I don't seem to get any results in the variable. So, I'm running a shell command, as follows:
E:\sun\dlc\bin\_mprshut.exe E:\sun\suncoast\db\training\training -C list
My next step is to check to see if the results contain a particular string. So, I'm using the "Check Variable" command, using "#global:cmdresults#", and choosing to check if the variable contains a string. In my tests the variable should contain the string, but the "Check Variable" doesn't find a match.
Is there something that I'm missing or using incorrectly??
Thanks very much,
What you are doing seems correct - you execute your shell command using "execute shell command - get results to variable" and can later use #global.cmdresults# as the output of the shell command. Two thoughts:
1) are you sure you've enabled the script step? (I must have accidentally missed this a thousand times)
2) is the shell command definitely finished before you attempt to refer to the output? As far as I know, execute shell command doesn't halt the procedure so if the output takes a bit of time perhaps you should add in a delay step to ensure the shell command completes before you start referring to the #global.cmdresults# variable?
What does the command output when you run it from the shell? Run it in a live connect command prompt since that runs as the SYSTEM user.
The command outputs a few lines of text. My intention is to search that text for a particular string, so that I can act on it. Is there a character limit for the "#global:cmdresults#"?
Thanks HTH! The script was indeed enabled, but it looks like you are correct about the shell command not halting the procedure. I assumed that it waited for the command to complete.... A Kaseya enhancement would be to add a "wait for command to complete" checkbox.
After adding a "Pause the procedure" step, the "#global.cmdresults#" had the expected value.
Hi, how do you enable the script step??
I quite often insert a "Write procedure log entry" step and get it to echo the variable. Something like:
===== Results = #global:cmdresults# =====
Then you can check the Procedure Log and see what's happening. It's great for debugging!