免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3690 | 回复: 7
打印 上一主题 下一主题

[系统] php exec ls 结果? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-09-17 15:47 |只看该作者 |倒序浏览
<?php
$a=exec("ls -al /home/demo/admin/include";
echo $a;
?>;

结果是:
-rw-r--r-- 1 demo nobody 30 Sep 17 14:44 test.php


其实我这里有很有很多文件呀,为什么只显示一条呢?

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
2 [报告]
发表于 2005-09-17 20:07 |只看该作者

[系统] php exec ls 结果?

It simply returns the last line from the result of the command.

http://w.yi.org/ftp/FAPM/PHP/php_manual_zh/function.exec.html

论坛徽章:
0
3 [报告]
发表于 2005-09-19 20:07 |只看该作者

[系统] php exec ls 结果?

<?php
$a=passthru("ls -al /home/demo/admin/include";
echo $a;
?>;
不过不能自动换行

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
4 [报告]
发表于 2005-09-20 08:38 |只看该作者

[系统] php exec ls 结果?

原帖由 "HonestQiao" 发表:
It simply returns the last line from the result of the command.

http://w.yi.org/ftp/FAPM/PHP/php_manual_zh/function.exec.html


这里说得很清楚,exec可能只返回最后一行,不知道有几个人看了?

论坛徽章:
0
5 [报告]
发表于 2005-09-20 08:55 |只看该作者

[系统] php exec ls 结果?

谢谢你哦,不过上上楼的说的也没错呀

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
6 [报告]
发表于 2005-09-20 09:20 |只看该作者

[系统] php exec ls 结果?

[quote]原帖由 "flowingtree"]谢谢你哦,不过上上楼的说的也没错呀[/quote 发表:


说你咧   

论坛徽章:
0
7 [报告]
发表于 2005-10-08 13:48 |只看该作者

[系统] php exec ls 结果?

请问怎样设置才能在php中运行exec()并得到结果呢?我的是linux10(fedora core)+apache2+php4    safe_mode=off   apache2的user/group=apache/apache   

<?php
$a=exec("ls ";
echo $a;
?>;
却得不到任何东西,错误返回值为127(找不到命令)

论坛徽章:
0
8 [报告]
发表于 2005-10-08 14:33 |只看该作者

[系统] php exec ls 结果?

exec
(PHP 3, PHP 4, PHP 5)

exec -- Execute an external program
说明
string exec ( string command [, array &output [, int &return_var]] )

返回值
The last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function.

To get the output of the executed command, be sure to set and use the output parameter.


$cmd = "ls /root";

exec($cmd,$out);

print_r($out);
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP