4 # File ID: 8f4bbf9c-5d3a-11df-b794-90e6ba3022ac
5 # (C)opyleft 1998 Oyvind A. Solheim <sunny@pils.kvarteret.uib.no>
6 # License: GNU General Public License version 2 or later.
9 $LastMd5 = substr(`md5sum /dev/null`,0,32);
10 $Extension = ""; # To avoid "Use of uninitialized value" warning.
13 print "md5sum /dev/null=\"$LastMd5\"\n" if $Debug;
14 # Syntax: getpic url [prefix] [ext]
16 print "argv = $#ARGV\n" if $Debug;
19 print "\nSyntax: $0 url sleeptime_in_seconds [prefix] [ext]\n\n";
24 $SleepTime = $ARGV[1];
25 $Prefix = $ARGV[2] if $#ARGV > 1;
26 $Extension = $ARGV[3] if $#ARGV > 2;
28 print "\$Url = \"$Url\"\n" if $Debug;
29 print "\$SleepTime = \"$SleepTime\"\n" if $Debug;
30 print "\$Prefix = \"$Prefix\"\n" if $Debug;
31 print "\$Extension = \"$Extension\"\n" if $Debug;
33 # die "Invalid sleeptime: $SleepTime" if ($SleepTime == 0);
34 $LastFile = "last.$Prefix$Extension.dat";
38 $FileName = $Prefix . &Utc
. $Extension;
39 $GetCommand = sprintf("wget -nv %s -O %s", $Url, $FileName);
40 # print "Executing \"$GetCommand\"..." if $Debug;
42 # print "returned $?\n" if $Debug;
43 $FileMd5 = substr(`md5sum $FileName`,0,32);
44 if ("$FileMd5" eq "d41d8cd98f00b204e9800998ecf8427e") {
45 print "******* $FileName has zero size, removing it. ********\n";
46 unlink($FileName) || warn "$FileName: Can't unlink file: $!";
50 $LastMd5 = `cat $LastFile`;
51 # print "\$FileMd5=\"$FileMd5\"\n" if $Debug;
52 # print "\$LastMd5=\"$LastMd5\"\n" if $Debug;
53 if ("$FileMd5" eq "$LastMd5") {
54 print "Removing $FileName.\n" if $Debug;
55 unlink $FileName || warn "$FileName: Can't unlink file: $!";
57 print "********* KEEPING $FileName *********\n" if $Debug;
58 system("echo -n $FileMd5 >$LastFile");
59 # open(LastFP,">$LastFile") or die "$0: $LastFile: Cannot create file: $!";
60 # print LastFP "$FileMd5";
61 # close(LastFP) || warn "$0: $LastFile: Can't close file: $!";
65 print "Sleeping for $SleepTime seconds..." if $Debug;
67 print "continuing.\n" if $Debug;
69 print "------------------------------------------------------------------------\n";
76 @TA=gmtime($FromSystem);
77 $UtcTime=sprintf("%04u%02u%02uT%02u%02u%02uZ", $TA[5]+1900, $TA[4]+1, $TA[3], $TA[2], $TA[1], $TA[0]);
87 This program is free software; you can redistribute it and/or modify it
88 under the terms of the GNU General Public License as published by the
89 Free Software Foundation; either version 2 of the License, or (at your
90 option) any later version.
92 This program is distributed in the hope that it will be useful, but
93 WITHOUT ANY WARRANTY; without even the implied warranty of
94 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
95 See the GNU General Public License for more details.
97 You should have received a copy of the GNU General Public License along
98 with this program; if not, write to the Free Software Foundation, Inc.,
99 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
103 #### End of file getpic ####