I'm having a quite frustrating problem than me and another engineer have pretty much exhausted our efforts towards.
Specs:
Windows 2000 Server - Two Week Old Install
PHP 4.3.8 - Grabbed CLI version as well
If I run the script from a command line (cmd) as follows, it connects and logs a successful connection to the OLE DB.
e:\program files\php\php-cli.exe testslx.php
But if I do the same thing in a scheduled task it always shows a failure in the log. This makes no sense! The scheduled task is running as Administrator (for tests).
Has anyone ever run into such behavior?
Here's the script:
<?php
error_reporting(0);
$recipients = 'sysadmin@xxxxxxx.net,techsupport@xxxxxxx.net';
$logfile = 'e:\\program files\\php\\testslx.log';
$dbc = new COM("ADODB.Connection");
$dbc->Open('Provider=SLXOLEDB.1;Password=password;Persist Security Info=True;User ID=xxxx;Initial Catalog=SALESLOGIX_SERVER;Data Source=XTNDSYNC1;Extended Properties="PORT=1706;LOG=ON"');
if ($dbc->State) {
success();
} else {
failure();
}
function success() {
logentry("SUCCESS: Connected to XTNDSYNC1 SalesLogix service.");
}
function failure() {
global $recipients;
$res = mail($recipients, "TESTING - PLEASE IGNORE -- XTNDSYNC1 Error: Could not connect", "Could not connect to XTNDSYNC1 SalesLogix Server.\r\nPlease verify system and service health.\r\n\r\nThis message was generated by the testslx monitor script.");
$pid = `c:\\Util\\tlist.exe -p SLXServer.exe`;
// `C:\\Util\\Kill.exe -f $pid`;
// sleep(3);
// `net start "SalesLogix Server"`;
logentry("ERROR: Could not connect to XTNDSYNC1 SalesLogix service. Mail result code was $res.");
}
function logentry($message) {
$date = date("[d/M/Y:G:i:s O]");
$logentry = "$date $message\r\n";
global $logfile;
if (!$handle = fopen($logfile, 'a')) {
echo "Cannot open file ($logfile)";
exit;
}
// Write logentry to our opened file.
if (fwrite($handle, $logentry) === FALSE) {
echo "Cannot write to file ($logfile)";
exit;
}
fclose($handle);
}
$dbc->Close();
$dbc = null;
?>