Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use strict; | ||
use warnings; | ||
|
||
require "/sdcard/ase/scripts/MyTools.pl"; | ||
|
||
use IO::Socket; | ||
|
||
use Android; | ||
my $d = Android->new(); | ||
|
||
|
||
my $site = 'http://perl.org/'; | ||
|
||
dd($d->getInput("URL", "Default: $site")); | ||
say(get($site)); | ||
|
||
|
||
sub get { | ||
my ($url) = @_; | ||
|
||
my $host = $url; | ||
$host =~ s{http://}{}; | ||
$host =~ s{/.*}{}; | ||
#print "$host\n"; | ||
|
||
my $port = 80; | ||
my $CRLF = "\015\012"; | ||
my $SIZE = 100; | ||
my $data = ''; | ||
|
||
my $socket = IO::Socket::INET->new( | ||
PeerAddr => $host, | ||
PeerPort => $port, | ||
Proto => 'tcp', | ||
) or die $!; | ||
|
||
|
||
$socket->send("GET $url$CRLF") or die $!; | ||
#print "sent\n"; | ||
|
||
while ($socket->read($data, $SIZE, length($data)) == $SIZE) { | ||
} | ||
|
||
return $data; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use strict; | ||
use warnings; | ||
|
||
require "/sdcard/ase/scripts/MyTools.pl"; | ||
|
||
|
||
say("Perl version: $]"); # reporting 5.010001 | ||
say("\$0 $0"); # /sdcard/ase/scripts/info.pl | ||
|
||
use File::Basename qw(dirname); | ||
say(dirname($0)); # /sdcard/ase/scripts | ||
|
||
use Cwd; | ||
say("cwd: " . cwd); # / (IMHO should be /sdcard/ase/scripts, question asked on list) | ||
|
||
say("Path to perl: $^X"); # /data/data/com.google.ase/perl/perl | ||
|
||
#print `ls -l`; | ||
# works | ||
# | ||
#print "pwd: ", `pwd`; | ||
# Can't exec "pwd": Permission denied | ||
|