3

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>";
mob
  • 117,087
  • 18
  • 149
  • 283
Mike Lodder
  • 31
  • 1
  • 3
  • Are you checking the return values of your system calls (`open`, etc.)? Are you checking the value of `$!` (and maybe `$^E`)? – mob Feb 14 '12 at 21:28
  • I have the open statement in an eval block and I am checking $@ afterwards. $@ is empty. – Mike Lodder Feb 14 '12 at 21:33
  • All that proves is that your open statement is valid syntax, not that it succeeded. Check the return value, and check `$!`. – mob Feb 14 '12 at 21:35
  • It returns 'Not a typewriter' That doesn't make any sense. – Mike Lodder Feb 14 '12 at 21:39
  • Here is the perl script. #!/data/data/com.googlecode.perlforandroid/files/perl/perl print "Content-type: text/html\r\n\r\n"; print " "; 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 " – Mike Lodder Feb 14 '12 at 21:52
  • [Not_a_typewriter](http://en.wikipedia.org/wiki/Not_a_typewriter) – mob Feb 14 '12 at 21:54
  • I remove the write to file stuff and try to print and I am still getting HTTP 506 IO Error – Mike Lodder Feb 16 '12 at 18:58

2 Answers2

1

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

JoseK
  • 31,141
  • 14
  • 104
  • 131
mj newbee
  • 11
  • 1
0

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

XcinnaY
  • 274
  • 2
  • 10