diff --git a/html/inc/btn_run_bu.php b/html/inc/btn_run_bu.php index 80ac7be..beec13f 100644 --- a/html/inc/btn_run_bu.php +++ b/html/inc/btn_run_bu.php @@ -8,7 +8,9 @@ //we cannot fork using php inside apache for some stupid reason. //so we need to deligate a fork to an external process. //BASH can do this with the background '&' command, so we use it. - + + global $g_phpcli_path; + $output = array(); $result_code = null; $bIsTest = $testrun=='true'; @@ -19,12 +21,17 @@ // get realpath, cos this is what is specified in visudo: //www-data ALL=(ALL) NOPASSWD: /usr/bin/php /var/www/html/bin/run-bu-by-id.php * $path_to_script = realpath(__DIR__."/../bin/run-bu-by-id.php"); - $command = "sudo php $path_to_script $buid $str_test"; + $command = "sudo $g_phpcli_path $path_to_script $buid $str_test 2>&1"; + + //error_log("btn_run_bu to execute cmd: $command"); if( exec( $command, $output, $result_code )===FALSE){ error_log( "exec to php-cli failed - command: $command"); return array('error', "exec to php-cli failed - command: $command" ); } + + //error_log( print_r($output,true) ); + //even though the script ran, it may have echoed errors to the console. We test here. if( count($output)>0 ){ if( substr( $output[0], 0, 6) == 'Error:' ){ diff --git a/html/inc/bu-common.php b/html/inc/bu-common.php index 7fd0c5a..29d14f7 100644 --- a/html/inc/bu-common.php +++ b/html/inc/bu-common.php @@ -124,9 +124,19 @@ $fn_e = getFilename_out( $buid, $bu_test, true ); // create the output files with the ID in the first line - exec("echo 'ID: $buid' > data/$fn_o"); - exec("echo 'ID: $buid' > data/$fn_e"); + //exec("echo 'ID: $buid' > data/$fn_o"); + //exec("echo 'ID: $buid' > data/$fn_e"); + //error_log("Attempt to create file $fn_e"); + + file_put_contents("data/$fn_o","ID: $buid"); + file_put_contents("data/$fn_e","ID: $buid"); + + if( !file_exists( "data/$fn_e" )){ + //file_put_contents( "/var/www/www-root/data/www/backup-commander/html/data/err_out.txt", "failed to create file $fn_e" ); + return "exec failed to create file $fn_e"; + } + $str_exPaths = ''; if(trim( $exFiles )!=''){ $fn_x = getFilename_tmp( $buid, 'x' ); diff --git a/html/inc/paths.php b/html/inc/paths.php index f1bfd5b..084ccd7 100644 --- a/html/inc/paths.php +++ b/html/inc/paths.php @@ -1,3 +1,4 @@