Kaseya Community

Doing something wrong running a script

This question is answered

It seems i'm making a goofup of some sort.

I'm trying to run a peace of SQL code on a Oracle database.

Basicly the script gets all health info I need on a daily bases.

I have made a Agent Procedure that copies two files to the client, and runs a .cmd file.

The files are copied, but the darn script will not run.

When I run the script manualy on the server, all works fine.

I tried to run as sysadmin & local user, none seems to help.

What am I doing wrong?

 

The Agent Procedure:


<?xml version="1.0" encoding="utf-8"?>
<ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
  <Procedure name="Apps - Oracle_Health_Check" treePres="3" id="186271677" folderId="65821141381762394161719125">
    <Body description="Do a Oracle healthchek &amp; parse results to logfile">
      <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false">
        <Parameter xsi:type="EnumParameter" name="VariableType" value="AgentTempDirectory" />
        <Parameter xsi:type="StringParameter" name="SourceContent" value="" />
        <Parameter xsi:type="StringParameter" name="VariableName" value="agentTmp" />
      </Statement>
      <Statement description="Write the selected file to the machine at the path specified - full path required." name="WriteFile" continueOnFail="false">
        <Parameter xsi:type="StringParameter" name="Path" value="#agentTmp#\healthchk_oracle.cmd" />
        <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\Daily_Checks\healthchk_oracle\healthchk_oracle.cmd" />
        <Parameter xsi:type="BooleanParameter" name="DeleteAfter" value="False" />
      </Statement>
      <Statement description="Write the selected file to the machine at the path specified - full path required." name="WriteFile" continueOnFail="false">
        <Parameter xsi:type="StringParameter" name="Path" value="#agentTmp#\healthchk_oracle.sql" />
        <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\Daily_Checks\healthchk_oracle\healthchk_oracle.sql" />
        <Parameter xsi:type="BooleanParameter" name="DeleteAfter" value="False" />
      </Statement>
      <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false">
        <Parameter xsi:type="StringParameter" name="Command" value="#agentTmp#\healthchk_oracle.cmd" />
        <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
        <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
      </Statement>
    </Body>
  </Procedure>
</ScriptExport>

 

The .CMD content:

del  %~dp0%healthchk_oracle_report.txt
SET SQL_FILE=%~dp0%healthchk_oracle.sql
SQLPLUS username/password @%SQL_FILE%

 

Example .SQL file content:

set linesize 132
set pagesize 1000
spool healthchk_oracle_report.txt
prompt IT WORKS
spool off
Exit

 

(Note that the real .sql file content is not shown here, as it involved a lot of work, and is now owned by our company.)

Verified Answer
  • We have found it.

    It seems that Kaseya cannot handle starting SQLPLUS without the file extention in the commandshell.

    So sqlplus will not run.

    sqlplus.exe will run.

    Strange, but noted.

    Goofup in Kaseya?

All Replies
  • What does %~dp0% represent in your healthchk_oracle.cmd? Maybe this outputs a user specific folder?

  • Stefan,

    %~dp0% is a cmd command to run somthing from the directry it was started in.

  • Yes, but what's the output of that command? Does it contain a user specific path (like C:\Users\<user>\AppData)?

  • We have found it.

    It seems that Kaseya cannot handle starting SQLPLUS without the file extention in the commandshell.

    So sqlplus will not run.

    sqlplus.exe will run.

    Strange, but noted.

    Goofup in Kaseya?