Android cgi web 服务器写入文件并加载 perl 脚本

发布于 2025-01-05 03:38:39 字数 1084 浏览 2 评论 0原文

我希望能够在运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谜兔 2025-01-12 03:38:39

我也有同样的问题。通过编辑新郎配置解决。

将 scipts 放在卡上的 cgi-bin 文件夹中。

确保脚本扩展 cgi 或 pl 在 groom 配置中列出,并且两者都由 groomcgihandler 处理,还要确保 groom.confscard/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 has scard/cgi-bin as the host directory i.e localhost:8080 will actually point straight to scard/cgi-bin

霞映澄塘 2025-01-12 03:38:39

您尝试在 /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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文