-1

I have tried exec, shell_exec, system but they didn't work for me.

<?php
shell_exec('gnome-terminal');
?>
Zubair Akber
  • 2,760
  • 13
  • 30
  • 1
    Did you get any error messages? – Daniel S. Sep 05 '13 at 07:59
  • 3
    Why would you want to do that? You need to sit at the machine to make use of that terminal, and if you do, you can just open it directly. – Thilo Sep 05 '13 at 08:00
  • I got no error message @DanielS. – Zubair Akber Sep 05 '13 at 08:02
  • Basically i want to execute a command './toolkits/collaborative_filtering/svdpp --training=/home/zubair/graphchi_v0.2.6/graphchi/smallnetflix_mm.train.txt --validation=/home/zubair/graphchi_v0.2.6/graphchi/smallnetflix_mm.validate.txt --binary_relevance_thresh=4 --sgd_gamma=1e-6 --max_iter=30 --quiet=1 --sgd_step_dec=0.9999 --sgd_lambda=1e-6 --D=3 --minival=1 --maxval=10' through php directly but it is not working so i think to open a terminal from php and than paste that command on that terminal.... May it works for me @Thilo – Zubair Akber Sep 05 '13 at 08:05

1 Answers1

0

It looks like you want to run binary file through php .... if it is Try this... Also make sure the binary file has 0777 permission

<?php 

//Command 
$cmd = './svdpp --training=/home/zubair/graphchi_v0.2.6/graphchi/smallnetflix_mm.train.txt --validation=/home/zubair/graphchi_v0.2.6/graphchi/smallnetflix_mm.validate.txt --binary_relevance_thresh=4 --sgd_gamma=1e-6 --max_iter=30 --quiet=1 --sgd_step_dec=0.9999 --sgd_lambda=1e-6 --D=3 --minival=1 --maxval=10';


//Binary Directory Path
$cwd = '/toolkits/collaborative_filtering/';

$descriptorspec = array (
        0 => array (
                "pipe",
                "r" 
        ),
        1 => array (
                "pipe",
                "w" 
        ),
        2 => array (
                "pipe",
                "r" 
        ) 
);

$process = proc_open ( $cmd, $descriptorspec, $pipes, $cwd );

if (is_resource ( $process )) {
    fclose ( $pipes [0] );

    echo 'Progress Output >> ' . stream_get_contents ( $pipes [1] );
    fclose ( $pipes [1] );

    echo 'Error >> ' . stream_get_contents ( $pipes [2] );
    fclose ( $pipes [2] );

    echo 'Proce_close >> '.proc_close ( $process );
}

?>
Rajesh R
  • 11
  • 1