Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php wkhtmltoimage的参数列表太长错误_Php_Arguments_Wkhtmltoimage - Fatal编程技术网

Php wkhtmltoimage的参数列表太长错误

Php wkhtmltoimage的参数列表太长错误,php,arguments,wkhtmltoimage,Php,Arguments,Wkhtmltoimage,我想捕获屏幕并将其存储到服务器。我使用下面的命令在php代码中实现了屏幕截图 $exec_command = "wkhtmltoimage --quality 10 --window-status 'wbcaptureready' --width 1200 --post 'estr' 'JTNDVFZXQiUzRSUzQ3diJTIwc0lkJTNEJTIyd2I3NzYyNzVpeWFma3hya3Qy9UVldCJTNF' --post 'ispagehasdocument' '0' --

我想捕获屏幕并将其存储到服务器。我使用下面的命令在php代码中实现了屏幕截图

$exec_command = "wkhtmltoimage --quality 10 --window-status 'wbcaptureready' --width 1200 --post 'estr' 
'JTNDVFZXQiUzRSUzQ3diJTIwc0lkJTNEJTIyd2I3NzYyNzVpeWFma3hya3Qy9UVldCJTNF' --post 'ispagehasdocument' '0' --height 1260 --enable-plugins --no-stop-slow-scripts https://example.org/page/capture/ '/data/screencapture/data/1234/1256/screenshots/screenshots/wbPage_^{4BEFBE59-EF14-4de4-9D08-3267BB76D8EA^}_0.png'";
$output = system($exec_command, $resCommand);
当我运行上面的代码时,它工作得很好。但是,当我将大量值文本传递给名为
estr
的参数时,当我回显
$resCommand
的值时,它抛出错误代码127(找不到命令)。当我尝试在putty中执行命令时,它会抛出如下错误

-bash: /usr/bin/wkhtmltoimage: Argument list too long
基于上面的错误,我上网冲浪,得到了建议,比如我必须增加
ARG_MAX
值。但这些建议并不明确和含糊。我找不到参数以及如何增加值

请建议我在何处以及如何增加
ARG_MAX
值,或者建议我是否有其他解决方案可以解决此问题

我的操作系统版本:-
Linux版本2.6.32-696.6.3.el6.x86_64(mockbuild@c1bl.rdu2.centos.org)(gcc版本4.4.7 20120313(Red Hat 4.4.7-18)(gcc))

谢谢,
Ravichandran

我无法测试它,但我相信下面的解决方法应该可以帮助您解决这个问题。最好保持ARG_MAX值不变,因为它可能有副作用

//This value can't have any spaces and as your string is base64encoded it shouldn't be a problem in your case.
$estrVal = 'JTNDVFZXQiUzRSUzQ3diJTIwc0lkJTNEJTIyd2I3NzYyNzVpeWFma3hya3Qy9UVldCJTNF';
//You can also create a unique file name instead of estr.txt & may be delete it later if not needed.
$estrFile = './path/to/estr.txt'; 
file_put_contents($estrFile, $estrVal);

$exec_command = "wkhtmltoimage --quality 10 --window-status 'wbcaptureready' --width 1200 --post 'estr' \"$(< ./path/to/estr.txt)\"
 --post 'ispagehasdocument' '0' --height 1260 --enable-plugins --no-stop-slow-scripts https://example.org/page/capture/ '/data/screencapture/data/1234/1256/screenshots/screenshots/wbPage_^{4BEFBE59-EF14-4de4-9D08-3267BB76D8EA^}_0.png'";

$output = system($exec_command, $resCommand);
//此值不能有任何空格,因为您的字符串是base64编码的,所以在您的情况下应该不会有问题。
$EstVal='jTndvfzxqiuzrsuzq3dijtiwc0lkjtneyd2i3nzyynzvpewfma3hya3qy9uvldcjtnf';
//您还可以创建一个唯一的文件名,而不是estr.txt&如果不需要,可以稍后删除它。
$estrFile='./path/to/estr.txt';
文件内容($estrFile,$estrVal);
$exec\u command=“wkhtmltoimage--quality 10--窗口状态'wbcaptureready'--width 1200--post'estr'\”$(
我建议您按如下方式运行它


$exec_command=“ulimit-s 65535&&wkhtmltoimage--质量10--窗口状态'wbcaptureaddy'--宽度1200--后期'estr'
“JTNDVFZXQiUzRSUzQ3diJTIwc0lkJTNEJTIyd2I3NzYyNzVpeWFma3hya3Qy9UVldCJTNF”--发布“ispagehasdocument”“0”--高度1260--启用插件--无停止-慢速脚本https://example.org/page/capture/ “/data/screenscapture/data/1234/1256/screenshots/screenshots/wbPage_u^{4bef59-EF14-4de4-9D08-3267BB76D8EA^}0.png”;
$output=系统($exec_命令,$resCommand);
这可能会增加参数列表的大小

php>$output=system(“getconf ARG_MAX”,$resCommand);
2097152
php>$output=system(“ulimit-s 65535&&getconf ARG_MAX”,$resCommand);
16776960

您能否共享导致错误的值?如果该值包含任何字符
$/\'“
@TarunLalwani No”,则该值不包含这些字符的$/\'”。这是base64编码的文本。可能是这个@TarunLalwani我清楚地提到了错误
参数列表太长
。我怎样才能解决这个问题?。是否有其他方法解决此问题?请确认长度是多少,然后会出现错误?我认为应该是
8192
我认为这个想法应该行得通。需要检查和确认。谢谢你的回复