易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP 调用shell命令

可以使用的命令:
popen
fpassthru
shell_exec
exec
system
1.popen
resource popen
( string command, string mode )
打开一个指向进程的管道,该进程由派生给定的 command
命令执行而产生。
返回一个和 fopen()
所返回的相同的文件指针,只不过它是单向的(只能用于读或写)并且必须用 pclose()
来关闭。此指针可以用于 fgets()
,fgetss()
和 fwrite()

如果出错返回 FALSE

2.shell_exec
string shell_exec
( string cmd )
执行cmd命令,命令的结果存在返回结果中;
本函数在安全模式
下被禁用。
3.exec
string exec
( string command [, array &output [, int &return_var]] )
参数:
command
将要执行的命令
output
如果指定了output参数,则对应的array数组将会填满该命令输出的每一行。
return_var
如果指定了return_var参数,注意,return_var参数只有output参数被设定后才能指定,那么该命令的执行状态将会以结果参数的形式返回给该变量。
返回值:
返回改名了的最后一行结果。
范例
例子 1. An exec() example
[root@south4 demo]# vi test.php
#!/usr/bin/php  -q
<?php
exec('ls /etc',$results,$ret);
echo  $results[5] . "\n";
echo  $results[12]. "\n";
echo  $results[3]. "\n";
echo  $ret;
?>
[root@south4 demo]# ./test.php
aliases
audit
adjtime
0
4.system
string system
( string command [, int &return_var] )
system是开一个bash进程的,执行完毕之后,就会释放,如下就会达不到目的:
system("cd /home/y/share/NBHadoop/scripts");
system("sudo -u yahoo ./nb_halfhourly.sh $yes_halfHour");
可以写成:
system("cd /home/y/share/NBHadoop/scripts;sudo -u yahoo ./nb_halfhourly.sh $yes_halfHour");


相关文档:

PHP的日期时间运算总结




<?php
//GB2312的Encode
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
/*重点了解strtotime()函数
1、strftime比time()好用,可以直接把常用的’2010-02-03‘转成时间戳。
2、date( ......

PHP数据结构——线性表的删除

function delete_array_element($arr,$i) {
$len = count($arr);
for($j=$i; $j<$len; $j++) {
$arr[$j] = $arr[$j+1];
}
array_pop($arr);//将数组的最后一个单元弹出
return $arr;
}
for($i=0; $i<10; $i++) {
$arr1[$i] = $i+1;
}
print_r($arr1);
echo "< ......

php分页函数

<?php
function page ( $totalPage , $currentPage,$url ,$halfPer=5)
{
$total=$totalPage-1;
$re="<td><a href="\" mce_href="\""$url\" onclick=\"page=prompt('共{$totalPage}页\\n自定义跳转到第几页:','');if(page>0&&page<$total)location.href=this.href+'='+(page-1);r ......

php生成扭曲及旋转的验证码图片

<?php
function make_rand($length="32"){//验证码文字生成函数
$str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
$result="";
for($i=0;$i<$length;$i++){
$num[$i]=rand(0,61);
$result.=$str[$num[$i]];
}
return $result;
} ......

windows 7下如何安装Apache + PHP + MySQL + SVN等等

近来对php比较感兴趣,就断断续续的花了两个星期的时间把整个php开发需要用到的东西都装好了,大概的安装过程如下。
一、安装的软件:
Apache: 2.2.14
PHP:5.2.12
MySQL:5.1.42。
SVN:1.5.6
PHPMyAdmin:3.2.5
Zend Studio: 7.1
Zend Debugger: 5.1.14
二、安装过程:
1. 安装和配置apache
安装:首先从http://apa ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号