Hello,
I'm stack with one problem and can not find aby solution in net or php.net documentation. So I decided to post here my problem hope someone will point me to some clue.
I'm tring to fire command line program using one of PHP functions: exec, system, etc... (no matter witch one I use). In my application I need to pass one parameter to it eg:
<?php
$param = 'foobar';
$output = exec("./some_script.o -e $param");
?>
Problem occures when the $param is longer then 229 signs. If so exec command returns empty $output. Very important clue is that it is not the problem of 'some_script.o' because when I fire it in debian shell it takes longer parametes. I feel in my neck that it is some kind of problem with configuration of PHP (some php.ini buffer size or something similar).
Any one of You face with sililar problem. I would appriciate any help.
Greetings
Pawel
Arguments lenght while execution shell commands problem
Moderator: General Moderators
- mecha_godzilla
- Forum Contributor
- Posts: 375
- Joined: Wed Apr 14, 2010 4:45 pm
- Location: UK
Re: Arguments lenght while execution shell commands problem
Hi,
I suggest this is probably not just a problem with PHP though it may be related - I looked through my php.ini and I couldn't see any settings for argument lengths in there. You might also want to check if exec() has any in-built limitations as well.
Failing that, have you tried look at something like xargs? Details here:
http://linuxdevcenter.com/pub/a/linux/lpt/09_21.html
For testing purposes, you could also try saving the arguments to a temporary file and then piping it to your application.
HTH,
Mecha Godzilla
I suggest this is probably not just a problem with PHP though it may be related - I looked through my php.ini and I couldn't see any settings for argument lengths in there. You might also want to check if exec() has any in-built limitations as well.
Failing that, have you tried look at something like xargs? Details here:
http://linuxdevcenter.com/pub/a/linux/lpt/09_21.html
For testing purposes, you could also try saving the arguments to a temporary file and then piping it to your application.
HTH,
Mecha Godzilla