Browse Source

Made watchdump.pl work on Windows (hopefully)

Alois Mahdal (@azzgoat) 11 years ago
parent
commit
3a0d69344c
3 changed files with 11 additions and 5 deletions
  1. 0
    2
      README.md
  2. 0
    1
      TODO.md
  3. 11
    2
      bin/watchdump.pl

+ 0
- 2
README.md View File

@@ -87,5 +87,3 @@ any text file that will fit your screen.
87 87
 For improved visual feedack, it will pre-pend the file contents with the file
88 88
 path and an "animation".  Display of the header can be controlled by options,
89 89
 see `--usage`.
90
-
91
-Note: Currently works only on UNIX-like systems.

+ 0
- 1
TODO.md View File

@@ -5,7 +5,6 @@ To-do:
5 5
         * mksheet.pl
6 6
         * htlogr: implement severities
7 7
         * htlogr: straighten up parameters
8
-        * watchdump.pl: make it work on Windows
9 8
 
10 9
     * document:
11 10
         * usage of mksheet.pl

+ 11
- 2
bin/watchdump.pl View File

@@ -35,12 +35,21 @@ sub get_frame {
35 35
     return $frame;
36 36
 }
37 37
 
38
+sub clear {
39
+    system "cls"    if -d "c:\\windows";
40
+    system "clear"  if -f "/bin/ls";
41
+}
42
+
38 43
 my $file = shift @ARGV or &usage;
39 44
 
40 45
 while (1) {
41
-    system("clear");
46
+    &clear;
42 47
     printf "[%s] watching: %s\n%s\n", &get_frame(), $file, "=" x 80
43 48
         unless $opts->{no_header};
44
-    print `cat $file`;
49
+    if (open my $fh, "<", $file) {
50
+        print join "", <$fh>;
51
+        close $file;
52
+    } else { warn "cannot open $file: $!\n"; next; }
53
+} continue {
45 54
     sleep $opts->{delay};
46 55
 }