[aprssig] PERL code to send objects to server

James Washer washer at trlp.com
Fri May 26 20:59:17 EDT 2006


Wouldn't a sprintf have been easier than all those ifs?
Something like
	 perl -e '$str=sprintf "%02d%02d%02d\n", 1,2,3;printf $str;'

Or, better yet, just use a "slice" of localtime, with something like.
	 perl -e '$datestamp= sprintf("%02d%02d%02d\n",(localtime())[3,2,1]);print $datestamp;'

On Sat, 27 May 2006 10:35:37 +1000
"Andrew Rich" <vk4tec at tech-software.net> wrote:

> sorted
> 
> #!/usr/bin/perl
> use Net::Telnet;
> $date2=time()-36000;
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($date2);
> if ($mday < 10) {
>     $day = "0".$mday;
> } else {
>     $day = $mday;
> }
> $month = $mon + 1;
> if ($month < 10) {
>     $month = "0".$month;
> }
> if ($hour < 10)
> {
> $hour = "0".$hour;
> }
> if ($min < 10)
> {
> $min = "0".$min;
> }
> $year+=1900;
> $date1 = $day.$hour.$min;
> my $host = "rotate.aprs.net";
> my $user = "";
> my $password = "";
> my $prompt = "";
> my (@data, $line);
> my $t = new Net::Telnet(Timeout     => '5', port => '10151');
> $t->errmode('return');
> $t->Net::Telnet::open($host);
> sleep 5;
> print $t "user VK4TEC-8 pass 21694 vers UI-View32 V1.92\n";
> sleep 5;
> $count =10;
> for ($i=0; $i < 20; $i++)
> {
> $count ++;
> print $t "VK4TEC-8>APU25C,TCPIP:;PLANE
> 25*".$date1."z27".$count.".80S/153".$count.".85E'test object\n";
> print "VK4TEC-8>APU25C,TCPIP:;PLANE
> 35*".$date1."z27".$count.".80S/153".$count.".85E'test object\n";
> sleep 5;
> }
> $t->close();
> 
> -----------------------------------------
> Andrew Rich
> Amateur radio callsign VK4TEC
> email: vk4tec at tech-software.net
> web: http://www.tech-software.net
> Brisbane AUSTRALIA
> 
>   -----Original Message-----
>   From: Andrew Rich [mailto:vk4tec at tech-software.net]
>   Sent: Saturday, 27 May 2006 6:31 AM
>   To: TAPR List
>   Subject: [aprssig] PERL code to send objects to server
> 
> 
>   Gudday
> 
>   Anyone got some perl code to connect to an aprs server and send objects ?
> 
>   Cheers
> 
>   here is my code
> 
>   #!/usr/bin/perl
>   #
>   # Sample data packet
>   # VK4TEC>APU25N,TCPIP*:
>   # ;12345678 *262014z2718.80S/15330.85E'test object
>   #
>   use Net::Telnet;
>   my $host = "rotate.aprs.net";
>   my $user = "";
>   my $password = "";
>   my $prompt = "";
>   my (@data, $line);
>   my $t = new Net::Telnet(Timeout     => '5', port => '10151');
>   $t->errmode('return');
>   $t->Net::Telnet::open($host);
>   sleep 5;
>   print $t "user VK4TEC-8 pass 21694 vers UI-View32 V1.92\n";
>   $lower=00;
>   $upper=60;
>   $random = int(rand( $upper-$lower+1 ) ) + $lower;
>   $lower2=00;
>   $upper2=60;
>   $random2 = int(rand( $upper2-$lower2+1 ) ) + $lower2;
>   $lower3=00;
>   $upper3=99;
>   $random3 = int(rand( $upper3-$lower3+1 ) ) + $lower3;
>   print $t "VK4TEC>APU25C,TCPIP:;12345578 *262015z2718.80S/15330.95E'test
> object\n";
>   sleep 5;
> 
> 
>   $t->close();
>   -----------------------------------------
>   Andrew Rich
>   Amateur radio callsign VK4TEC
>   email: vk4tec at tech-software.net
>   web: http://www.tech-software.net
>   Brisbane AUSTRALIA
> 
> 




More information about the aprssig mailing list