patch-GetKp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. $OpenBSD: patch-GetKp,v 1.3 2008/06/20 10:49:42 martynas Exp $
  2. --- wmSpaceWeather/GetKp.orig Fri Feb 12 06:42:01 1999
  3. +++ wmSpaceWeather/GetKp Thu Jun 19 20:41:26 2008
  4. @@ -7,19 +7,31 @@
  5. require "ctime.pl";
  6. + #
  7. + # Change to users home directory. We used to dump into /tmp
  8. + # but using home dir instead avoids multiple users interfering
  9. + # with one another. (Yeah, we could "unique-ize" the filenames, but
  10. + # this is easier for now...)
  11. + #
  12. + $home = (getpwuid($<))[7];
  13. + $ok = chdir() || chdir($home);
  14. - ($Year, $Month, $Day) = &year_month_day();
  15. -
  16. - if (-e "/tmp/DGD.txt"){
  17. - unlink("/tmp/DGD.txt");
  18. + #
  19. + # Check to see if .wmSpaceWeatherReports exists.
  20. + # If not, make it and move to it.
  21. + #
  22. + if ( !(-e ".wmSpaceWeatherReports") ){
  23. + mkdir(".wmSpaceWeatherReports", 0775);
  24. }
  25. + chdir(".wmSpaceWeatherReports");
  26. + unlink("DGD.txt");
  27. + unlink("curind.txt");
  28. - if (-e "/tmp/curind.txt"){
  29. - unlink("/tmp/curind.txt");
  30. - }
  31. + ($Year, $Month, $Day) = &year_month_day();
  32. - $grabcmd = "cd /tmp; wget --passive-ftp --tries 2 -q ftp://www.sec.noaa.gov/pub/indices/DGD.txt";
  33. +
  34. + $grabcmd = "ftp -V ftp://www.sec.noaa.gov/pub/indices/DGD.txt";
  35. system "$grabcmd";
  36. @@ -37,7 +49,7 @@
  37. $Kp{190001018} = 999;
  38. - open(TmpFile, "/tmp/DGD.txt");
  39. + open(TmpFile, "DGD.txt");
  40. while (<TmpFile>){
  41. chop;
  42. if ($_ =~ /^\d{4} \d{2} \d{2}\s*\d*/ ){
  43. @@ -68,12 +80,12 @@
  44. #
  45. # Add in very latest stuff
  46. #
  47. - $grabcmd = "cd /tmp; wget --passive-ftp --tries 2 -q ftp://www.sec.noaa.gov/pub/latest/curind.txt";
  48. + $grabcmd = "ftp -V ftp://www.sec.noaa.gov/pub/latest/curind.txt";
  49. system "$grabcmd";
  50. %lmonstr = ( "Jan", 1, "Feb", 2, "Mar", 3, "Apr", 4, "May", 5, "Jun", 6, "Jul", 7, "Aug", 8, "Sep", 9, "Oct", 10, "Nov", 11, "Dec", 12);
  51. @lval = ($lyear, $lmonstr{$lmon}, $ldom);
  52. - open(TmpFile, "/tmp/curind.txt");
  53. + open(TmpFile, "curind.txt");
  54. while (<TmpFile>){
  55. chop;
  56. if ($_ =~ /^:Geomagnetic_Values: (\d{4}) (.*) (\d{1,2})/){
  57. @@ -133,7 +145,7 @@
  58. }
  59. }
  60. - open(TmpFile, ">/tmp/LatestKp.txt");
  61. + open(TmpFile, ">LatestKp.txt");
  62. foreach $key (sort keys %Result ) {
  63. if ($Result{$key} > 10) { $Result{$key} = -1; }
  64. printf TmpFile "$key $Result{$key}\n";