Android cgi web 服务器写入文件并加载 perl 脚本
我希望能够在运行 Android 3.2 的三星 Galaxy 平板电脑上运行 CGI 应用程序。 我已经安装了 GroomDroid、SL4A 和 PerlForAndroid。
我将groom.conf 文件放入/sdcard 目录中并启动GroomDroid。
我将 Perl 脚本放在 /data/perlapp 文件夹中,并使 Perl 文件可执行并使父文件夹可写。
所有文件正在执行的操作都是运行打印语句。当我访问 Perl 脚本时,生活很美好。我按照预期看到了网页,就像在计算机上一样。
现在,如果我尝试从 perl 脚本创建文件,则会收到 HTTP 506 IO 错误。
有什么想法为什么我会得到这个吗?
即使 perl 文件位于同一目录中,我也无法让 require 语句起作用。
非常感谢这里的任何帮助。
我试图运行的代码:
#!/data/data/com.googlecode.perlforandroid/files/perl/perl
print "Content-type: text/html\r\n\r\n";
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"w3.org/TR/html4/loose.dtd\"";
print "<html><body style=\"font-family: arial; margin: 20px;\"><span style=\"color:red; font-weight: bold; padding-right: 10px;\">";
eval {
open(FILE, ">>/data/scwi/data/temp.cgi") or print $!;
print FILE "respondent 1\n";
close(FILE);
};
print $!;
if ($!) {
print "Error";
} else {
print "Success";
}
print "</span></body></html>";
I want to be able to run a cgi application on my samsung galaxy tablet running android 3.2.
I have installed GroomDroid, SL4A, and PerlForAndroid.
I put my groom.conf file in my /sdcard directory and start GroomDroid.
I put my perl scripts in the /data/perlapp folder and make the perl files executable and make the parent folder writable.
All the files are doing is running print statements. When I access the perl scripts life is good. I see the web page as expected just like I would on a computer.
Now if I try to create files from the perl scripts I am getting HTTP 506 IO Error.
Any ideas why I would be getting this?
I call cannot get a require statement to work even if the perl files are in the same directory.
Any help here is greatly appreciated.
The code I am trying to run:
#!/data/data/com.googlecode.perlforandroid/files/perl/perl
print "Content-type: text/html\r\n\r\n";
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"w3.org/TR/html4/loose.dtd\"";
print "<html><body style=\"font-family: arial; margin: 20px;\"><span style=\"color:red; font-weight: bold; padding-right: 10px;\">";
eval {
open(FILE, ">>/data/scwi/data/temp.cgi") or print $!;
print FILE "respondent 1\n";
close(FILE);
};
print $!;
if ($!) {
print "Error";
} else {
print "Success";
}
print "</span></body></html>";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也有同样的问题。通过编辑新郎配置解决。
将 scipts 放在卡上的 cgi-bin 文件夹中。
确保脚本扩展 cgi 或 pl 在 groom 配置中列出,并且两者都由 groomcgihandler 处理,还要确保
groom.conf
将scard/cgi-bin
作为主机目录即 localhost:8080 实际上会直接指向scard/cgi-bin
I had the same problem. Solved by editing groom config.
place scipts in cgi-bin folder on the scard.
make sure the script extension cgi or pl is listed in groom config and both are dealt with by groomcgihandler, also make sure
groom.conf
hasscard/cgi-bin
as the host directory i.e localhost:8080 will actually point straight toscard/cgi-bin
您尝试在 /data/ 目录中写入文件。
您确定您有权写入此目录吗?
首先,尝试在/sdcard/目录中写入,它是全局可写的。
然后使用 stat() 函数检查您是否有足够的权限在目录中写入
You try to write a file in the /data/ directory.
Are you sure you have the access to write in this directory?
First, try to write in the /sdcard/ directory, it is world writable.
Then check if you enough right to write in the directory using the stat() function