ProHill/VRS-flights-db - flightimport.php issue

Want to post something that doesn't quite fit into the other forums? This is the place for that.
Post Reply
Laban
Posts: 10
Joined: Thu Jan 26, 2017 1:34 pm

ProHill/VRS-flights-db - flightimport.php issue

Post by Laban » Tue Feb 14, 2017 1:39 pm

Hello,

Posting to this forum - hoping it's the right place.

I've got the ProHill package setup locally on a Windows 10 box with a Xampp "server" (php, MariaDB (mysql)) - modified the ProHill package to operate more local in a sense (no puTTy).

I can get a cronjob to export BaseStation.sqb to the flights.csv file ok (with the exception that BaseStation.sqb locks up after a while - separate issue).
I can import the flights.csv data to my database OK running flightimport.php in my browser.

But every attempt to automate the import through Task Scheduler or schtasks ie a cronjob fails - I believe there is something within flightimport.php that I don't get :)


Below is my latest attempt:

All files are located in same directory.
Made a php_execute.bat file to setup the scheduled task (run test1.php):

Code: Select all

SCHTASKS /create /RU SYSTEM /SC MINUTE /MO 1 /TN "Flight_Import" /TR "C:\xampp\php\php-win.exe -f C:\xampp\htdocs\flights\test1.php"
Yes, I know the 1 min modifier is to freequent but it is for testing purposes

My file test1.php - it dumps the time of execution into flight_import.txt then includes flightimport.php

Code: Select all

<?php
// Dump execution log to flight_import_log.txt
date_default_timezone_set('Europe/Stockholm');
$dump_time = date('Y-m-d H:i:s');
$dump_file = "C:/xampp/htdocs/flights/flightimport_log.txt";
file_put_contents($dump_file, "File Executed on:$dump_time\r\n", FILE_APPEND);

// Include flightimport file
include 'flightimport.php';
?>
The result is a nice flight_import_log.txt with entries but no execution of the flightimport.php.

If I run my test1.php file in a browser - it executes the import flawlessly.

Any bright ideas?

Laban
Posts: 10
Joined: Thu Jan 26, 2017 1:34 pm

Re: ProHill/VRS-flights-db - flightimport.php issue

Post by Laban » Thu Feb 23, 2017 2:13 pm

After a long ardous process (not that proficient in this area) I've established that any and all cronjobs via the command line do not like to include anything.

I.E the following will not work (I'm running a xampp server):

Code: Select all

c:\xampp\php\php.exe -f c:\xampp\htdocs\flights\flightimport.php
flightimport.php is attempting to include both config.php and (through config.php) the flighs.csv file - no go.

The solution was to execute the flightimport.php file through an URL - I made a new php file called flightimport_execute.php:

Code: Select all

<?php 
// Execute flightimport.php file via URL
file_get_contents('http://localhost:8080/flights/flightimport.php');

// Dump execution log to flight_import_log.txt
date_default_timezone_set('Europe/Stockholm');
$dump_time = date('Y-m-d H:i:s');
$dump_file = "C:/xampp/htdocs/flights/flightimport/flightimport_log.txt";
file_put_contents($dump_file, "MySQL Import Executed on:$dump_time\r\n", FILE_APPEND);
exit();
?>
I simply let the .bat file run this php file instead which parses the file as an url instead.

The DUMP is just to log the import into a .txt file.

Post Reply