How to call an Automic job from PHP

Discussion created by Mitch_Denis_38 on May 22, 2014
Latest reply on May 23, 2014 by Wolfgang_Brueckler_75

We had a question the other day of how to call jobs in Automic from a webpage and the ECC was not an option.  I figured I would give one example of how to do this with PHP script.  We use this method for some of our internal php pages within Support.  I'll post another with examples of WebServices in a bit.

Please feel free to give your additions to this.  Also, please note I am not a web developer and cannot be held responsible for bad coding practices.   ;)


  • Some php and html (forms) knowledge
  • A web server that can compile php pages and has access to the CP port through the CallAPI
  • CallAPI files (for Windows) in the folder holding the php files
  • In this example, the ini file is set up correctly and the CallAPI was tested beforehand

PHP File contents:

<?php if ($_POST['formSubmitName'] == "Submit") {    //be sure that a name has been entered    $errorMessage = "";      if(empty($_POST['formUserName']))    {      $errorMessage .= "<li>Please enter a name.</li>";    }    //get user name from form    $varUserName = $_POST['formUserName'];    if(empty($errorMessage))     {    //write to activate_script.txt - if it does not exist, this will create it.      $fs = fopen("activate_script.txt","w");         // use PUT_READ_BUFFER to pass in values - the SCRI on the other side will use :READ        fwrite($fs, ":PUT_READ_BUFFER name#='".$varUserName. "' \r\n");         // Activate SCRI.HELLO.NAME        fwrite($fs, ":set &job#=activate_uc_object(SCRI.HELLO.NAME)". "\r\n");         // Print the job runnr        fwrite($fs, ":p &job#". "\r\n");      fclose($fs);       //run activate_object.bat with with the script being activate_script.txt      $output = shell_exec('activate_object.bat activate_script.txt');       // echo the command line output to the page.      echo $output;      exit;    } } ?> <html> <body> <div id="form_container">    <form method="post" ">          <label>Enter your name below</label>            <br/>          <input id="formUserName" name="formUserName" type="text" maxlength="255" value=""/>             <br/>          <input id="formSubmitName" class="button_text" type="submit" name="formSubmitName" value="Submit" />    </form>   </div> </body> </html>

BATCH FILE CONTENTS (%1 comes in here as "activate_script.txt")

ucxbxxxc.exe script=%1

SCRI.HELLO.NAME Process tab contents:

:read &name#, , 'name' ,
: p 'Hello &name#!'