Skip to content

Commit

Permalink
adding two more
Browse files Browse the repository at this point in the history
  • Loading branch information
xsawyerx committed May 29, 2010
1 parent 2d5d4d4 commit 8223dff
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
46 changes: 46 additions & 0 deletions scriptlets/get.pl
@@ -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;
}

23 changes: 23 additions & 0 deletions scriptlets/info.pl
@@ -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

0 comments on commit 8223dff

Please sign in to comment.