Kaseya Community

Catching return values from shell commands

  • First of all, a big fat thank you to all of you who've helped me along the way. Getting this service desk module even to limp (we are far from running) has been more of a challenge than i was hoping for. So thanks.

    And now to question number one. There'll be a second one shortly.

    In our service desk process, the customer may get billed a Service Credit or for Consulting Hours (depending on a few variables, but that's thankfully beyond the scope of this discussion). Since there currently isn't much of a billing mechanism in Kaseya -- i can't even get a custom field assigned to an Organization that would hold the number of remaining Service Credits -- the billing activity must take place outside Kaseya, but triggered by it. 

    Enter External Shell Commands. When my ticket enters the "Bill the customer" stage, the required variables are checked and if we're good to go, an external shell command c:\bin\kaseya\bill.cmd $TicketId$  is executed with Wait to complete and Send output to log file checked. On the server side i currently just have a test script -- 

    @echo off
    echo %DATE% %TIME% Billing %1 >> c:\bin\kaseya\billing.log
    echo OK %DATE% %TIME%

    -- that appends the event to a log file and returns the text string OK appended by a timestamp.

    So far so good.

    I've also configured the return value "to be written to this variable:" ret

    In the next step, i want to set the ticket's custom field Billing_status with the value of ret as above. This is where it fails. I've tried setting Billing_status to [=ret=] and [$ret$] but i only get errors. In the end, the Billing_status value is "* Field ret Error *"

    So with a long intro and a short question, what am i doing wrong and what should i do to do it right?

     ~rL

     

  • I tried adding an IF statement to check for the existence of the string OK within the variable ret. Seems that it always fails even though the script is hard wired to emit the string OK. Judging from the output.log i'm using, DOS maybe adds an extra line feed to the return value and maybe that's why it fails.

    I'm still very confused with the variable notations, so i added a debug line to add a note with <ret>, [#ret#], [$ret$] and [=ret=]. The angles turned out blank, the hashes came back as literal [#ret#], dollars returned " * Field ret Error * ", and equals " *Invalid Variable: ret* "

    It seems like any way i try, i lose. Now my guess is that i'm not assigning the variable the right way in the Execute Shell Command line. And i can't find the right syntax in the IF sentence i added.