简体   繁体   中英

Execute WinHTTrack command with PHP

I just want to execute command from my localhost. A WinHTTrack tool for website copier installed on my system. When i am using Windows Command Line to execute this command. it is working fine. But with PHP No result...

A code sample here :

<?php

echo exec("C:\Program Files\WinHTTrack\httrack 'http://in.yahoo.com/example_page.html' -O 'save_folder/in.yahoo.com/' '+in.yahoo.com/*' -v");    

?>

Updated Question Hello

With this code i just want to test httrack command line exec on windows for my future use.

$url = 'http://myweb.com/index.html';
$dest = '/tmp/';
echo $command = 'C:\Program Files\WinHTTrack\httrack ' .$url. ' -O ' .$dest. ' +myweb.com/* -v';        
echo exec($command, $output,$error); 
print_r($output);
print_r($error);    

Output: Array()

Error : 1

failed. no result :(

But when i am running manually form windows command line

C:\Program Files\WinHTTrack\httrack http://myweb.com/index.html -O /tmp/ +myweb.com/* -v

Giving me a accurate result. any solution please.

see in php.ini if this function enabled

disable_functions =exec

and omit here

also see the output like:

 exec("my command", $output);
 print_r($output);

Path to WinHTTrack contains space. You need to escape this path (and arguments too) but not with ', instead use escapeshellarg().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM