Showing posts with label Shell_exec. Show all posts
Showing posts with label Shell_exec. Show all posts

Friday 22 March 2019

How to make backgroud process in php using shell_exec

Create background.php file
<?php
$post_id = ['post_id'=>10];
$post_id = json_encode($post_id);
$pid = shell_exec("php /var/www/html/magento/dump/exportfile.php $post_id alert >> /var/www/html/magento/dump/test.log & echo $!");
echo $pid;
Create checkprocess.php file
$pid = 1254; // Copy pid from background.php
if (file_exists("/proc/$pid" )){
    echo "process with a pid = $pid is running";
}
 Create exportfile.php file
//Create this file with high time taking script

Tuesday 5 June 2018

shell_exec("mysql -u $dbuser --password='$dbpassword' --host='$sqlhost' $dbname < $file") not working in PHP

I try to execute query from PHP / CMD / Terminal


mysql -u admin --password='jaydip' --host='localhost' 'mg_kansagra' < '/var/www/html/magento/dump/db.sql'


Its show me following error

mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 3167 (HY000) at line 17: The 'INFORMATION_SCHEMA.SESSION_VARIABLES' feature is disabled; see the documentation for 'show_compatibility_56'

ANSWER

Run the following query in your MySQL database:
set @@global.show_compatibility_56=ON;

Monday 6 June 2016

How to run URL Using exec, Shell_exec in php

function testf(){
        $url = 'http://www.google.com';
        $outputfile = "jems.html";
        $cmd = "wget -q \"$url\" -O $outputfile";
        exec($cmd);
        echo file_get_contents($outputfile);
    }