Advertisement
dragonflydiy

Weather underground upload script

Dec 16th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. # upload the first image we come to in this path then delete the rest
  4. my $uri = "webcam.wunderground.com";
  5. my $uid = "(camname)";
  6. my $pw = "(password)";
  7.  
  8. my $path = "/home/jrr/Pictures/sunsetcam";
  9.  
  10. open(LOG, ">>$path/upload.log");
  11.  
  12. my @files = <$path/*jpg>;
  13.  
  14. my $any = 0;
  15. foreach my $f (@files)
  16. {
  17. if (!$any)
  18. {
  19. upload($f);
  20. $any = 1;
  21. }
  22. unlink($f);
  23. }
  24.  
  25. sub upload
  26. {
  27. my ($f) = @_;
  28. my $cmd = "curl -T $f ftp://$uid:$pw\@$uri";
  29. print LOG "$cmd\n";
  30. system($cmd);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement