Chinaunix
标题:
shell编的cgi如何使用>重定向
[打印本页]
作者:
ouyxia
时间:
2010-11-23 15:10
标题:
shell编的cgi如何使用>重定向
位大侠好
在用shell编写的cgi中,怎么使用重定向到另一个文件里。
top > ./top.log
以下是一个用shell编的CGI程序
#!/bin/bash
echo "Content-Type:text/html"
echo ""
echo "<html>"
echo "<pre>"
top > ./top.log
echo "</pre>"
echo "</html>"
但是top > ./top.log 这个命令是不能执行的。。我现在就想使用这种重定向到一个文件里。
作者:
yinyuemi
时间:
2010-11-23 15:42
top >> ./log.txt
这个可以么?
作者:
ouyxia
时间:
2010-11-23 15:50
回复
2#
yinyuemi
不行哦,在调用cgi的时候,那个top > ./top.txt.这句是不能执行的,最初我还怀疑是权限问题,我设置了suid也不行。。。
作者:
lkk2003rty
时间:
2010-11-23 16:10
top -b -n 1
作者:
ouyxia
时间:
2010-11-23 16:15
回复
4#
lkk2003rty
top -d 5 -n 1 > ./top.txt 这样也不行的。。感觉就是他不支持后面这个重定向。
作者:
lkk2003rty
时间:
2010-11-23 17:17
回复
5#
ouyxia
可以的。。。。你的环境? RH Ubuntu 俺都试了
作者:
waker
时间:
2010-11-24 09:58
回复
5#
ouyxia
nobody对目录有写权限么?
作者:
ouyxia
时间:
2010-11-24 13:01
#!/bin/bash
echo "Content-Type:text/html"
echo ""
echo "<html>"
echo "<pre>"
top -d 5 -n 1 >> ./top.log
echo "</pre>"
echo "</html>"
我是通过网页的形式调用这个CGI程序,但是这个CGI程序不运行top -d 5 -n 1 >> ./top.log 这条命令。
我的是suse 10
作者:
lkk2003rty
时间:
2010-11-24 13:15
回复
8#
ouyxia
报错信息是啥?
作者:
ouyxia
时间:
2010-11-24 13:22
回复
9#
lkk2003rty
没任何错误。
作者:
fly_jiang
时间:
2012-05-30 10:19
回复
10#
ouyxia
帮忙顶一下我也遇到了。。。
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2