package II::Get; use LWP::Simple; use II::DB; use Data::Dumper; sub new { my $class = shift; my $self = { _config => shift, }; bless $self, $class; return $self; } sub get_echo { my ($self) = @_; my $config = $self->{_config}; my $echoareas = $config->{echoareas}; my $host = $config->{host}; my $db = II::DB->new(); my $echo_url = 'e/'; my $msg_url = 'm/'; my $msgs; foreach my $echo (@$echoareas) { # my @content = get( "$host" . "$echo_url" . "$echo" ); my @content = `curl $host$echo_url$echo`; # if ( is_success( getprint( "$host" . "$echo_url" . "$echo" ) ) ) { # Write echoes file open my $echo_fh, ">", "./echo/$echo" or die "Cannot open file: $!\n"; print $echo_fh @content; close $echo_fh; # Get messages open my $echo_fh, "<", "./echo/$echo" or die "Cannot open file: $!\n"; while (<$echo_fh>) { chomp($_); if ( !( -e "./msg/$_" ) ) { $msgs .= $_ . "\n"; # @w_cmd = ( 'wget', '-O', # "./msg/$_", "$host" . "$msg_url" . "$_" ); `curl $host$msg_url$_ > ./msg/$_`; # system(@w_cmd) == 0 or die "Cannot download file: $!\n"; } } close $echo_fh; # } } my $new_messages = "