Mohamed
Mohamed

Reputation: 123

Pass long string through exec

When I try to pass a short string it passes, and when I try to pass a longer string It doesn't pass.

Here's the code I'm using :

index.php

function bgExec($cmd) {
 if(substr(php_uname(), 0, 7) == "Windows"){
  pclose(popen("start /B ". $cmd, "r")); 
 }else {
  exec($cmd . " > /dev/null &"); 
 }
}

$string = "some long string";

bgExec("php -q process.php $string");

process.php

file_put_contents('file.txt', print_r($argv[1], true));

Is there any solution to pass a longer string ?

Upvotes: 0

Views: 160

Answers (1)

Milan Rezny
Milan Rezny

Reputation: 11

For long data use pipe, or give only path to the input data.

Upvotes: 1

Related Questions