Problem mit IPCAM und sendSnapshot

Begonnen von ezekiel1111, 02 April 2013, 23:54:59

Vorheriges Thema - Nächstes Thema

ezekiel1111

Hallo,

ich habe ein Problem mit IPCAM und sendsnapshot. Das Modul funktioniert und die Bilder meiner IP CAM werden auf die Fritzbox geschrieben. Nun wollte ich die Funktion sendSnapshot integrieren (fischer-net.de), wenn ich aber den auf der Homepage angegebenen Code.....


#######################################
sub
sendSnapshot(@)
{
  my ($cam,$snapshots) = @_;
  my $storage = AttrVal($cam,"storage","");
  my $rcpt = '<your_email_address>';
  my $from = '<from_email_address>';
  my $subj = "FHEM: Kamera $cam hat eine Bewegung aufgezeichnet";
  my $last = ReadingsTimestamp($cam,"last","");
  my $mess = "Kamera $cam hat eine Bewegung am $last aufgezeichnet:";<br>
  if(!-d $storage) {
    Log 1, "IPCAM $cam storagepath does not exists: $storage";
    return "storagepath for $cam does not exists: $storage";
  }
  if(!$last) {
    Log 1, "IPCAM $cam no snapshots available";
    return "no snapshots available for $cam";
  }<br>
  my $cmd  = "sendemail -f $from -t $rcpt -u $subj -m $mess ";
     $cmd .= "-o message-content-type=text -o message-charset=utf-8 -a";
  for (my $s=1;$s<$snapshots+1;$s++) {
    $cmd .= " $storage/".ReadingsVal($cam,"snapshot$s","");
  }
  my $ret  = `$cmd`;
  $ret =~ s/[\r\n]//g;
  Log 4, "IPCAM sendSnapshot: $ret";
  return undef;
}<br>
1;


.....in 99_utils.pm einbaue, bekomme ich folgende Fehlermeldungen:

syntax error at ./FHEM/99_Utils.pm line 190, near ") {" Global symbol "$last" requires explicit package name at ./FHEM/99_Utils.pm line 194. Global symbol "$cam" requires explicit package name at ./FHEM/99_Utils.pm line 195. Global symbol "$cam" requires explicit package name at ./FHEM/99_Utils.pm line 196. syntax error at ./FHEM/99_Utils.pm line 198, near "my " Global symbol "$cmd" requires explicit package name at ./FHEM/99_Utils.pm line 198. Global symbol "$cmd" requires explicit package name at ./FHEM/99_Utils.pm line 199. Global symbol "$snapshots" requires explicit package name at ./FHEM/99_Utils.pm line 200. Global symbol "$cmd" requires explicit package name at ./FHEM/99_Utils.pm line 201. Global symbol "$storage" requires explicit package name at ./FHEM/99_Utils.pm line 201. Global symbol "$cam" requires explicit package name at ./FHEM/99_Utils.pm line 201. Global symbol "$cmd" requires explicit package name at ./FHEM/99_Utils.pm line 203. syntax error at ./FHEM/99_Utils.pm line 207, near "}" ./FHEM/99_Utils.pm has too many errors.


Da ich kein Informatiker bin habe ich leider keine Ahnung, wo der Fehler liegt!?
Vielen Dank schon im Voraus für Eure Antworten.

VG
ezekiel1111

Vladi2010

hallo zusammen habe das gleiche Problem allerdings auf einem Paspberry,
hat jemand schon die Lösung ?

2014.02.28 11:56:11 1: Including fhem.cfg
2014.02.28 11:56:12 1: reload: Error:Modul 99_myUtils deactivated:
syntax error at ./FHEM/99_myUtils.pm line 70, near ") {"
Global symbol "$last" requires explicit package name at ./FHEM/99_myUtils.pm line 74, <$fh> line 3.
Global symbol "$cam" requires explicit package name at ./FHEM/99_myUtils.pm line 75, <$fh> line 3.
Global symbol "$cam" requires explicit package name at ./FHEM/99_myUtils.pm line 76, <$fh> line 3.
syntax error at ./FHEM/99_myUtils.pm line 78, near "my "
Global symbol "$cmd" requires explicit package name at ./FHEM/99_myUtils.pm line 78, <$fh> line 3.
Global symbol "$cmd" requires explicit package name at ./FHEM/99_myUtils.pm line 79, <$fh> line 3.
Global symbol "$snapshots" requires explicit package name at ./FHEM/99_myUtils.pm line 80, <$fh> line 3.
Global symbol "$cmd" requires explicit package name at ./FHEM/99_myUtils.pm line 81, <$fh> line 3.
Global symbol "$storage" requires explicit package name at ./FHEM/99_myUtils.pm line 81, <$fh> line 3.
Global symbol "$cam" requires explicit package name at ./FHEM/99_myUtils.pm line 81, <$fh> line 3.
Global symbol "$cmd" requires explicit package name at ./FHEM/99_myUtils.pm line 83, <$fh> line 3.
syntax error at ./FHEM/99_myUtils.pm line 87, near "}"
./FHEM/99_myUtils.pm has too many errors.



# $Id: 99_myUtils.pm 2013-04-24

package main;
use strict;
use warnings;
use POSIX;

sub myUtils_Initialize($$)
{
  my ($hash) = @_;
}



sub doWertListeBrenner {
   my @wert;
   my $div_class;
   $div_class = "WertListe";   # format in css-file using #WertListe
   my $header = "01 Brennerstatistik";
# Werteliste zusammenstellen
   $wert[0] = "heutige Brennerstarts: "      .','.   ReadingsVal("CN.Test","countsPerDay","Fehler");
   # sub cntFmtTime aus 99_UtilsMaxCounter.pm
   $wert[1] = "letzter Brennzyklus (h:m:s): "   .','.   cntFmtTime(ReadingsVal("CN.Test","pulseTimeIncrement","Fehler"));
   
   $wert[2] = "Tagesbrenndauer (h:m:s): "   .','.   cntFmtTime(ReadingsVal("CN.Test","pulseTimePerDay","Fehler"));
   $wert[3] = "Tagesoelverbrauch (l): "      .','.   sprintf("%8.2f", ReadingsVal("CN.Test","pulseTimePerDay","Fehler")/3600*2.12195121951);
   $wert[4] = "Gesamtbrenndauer (h:m:s): "      .','.   cntFmtTime(ReadingsVal("CN.Test","pulseTimeOverall","Fehler"));
   $wert[5] = "Gesamtoelverbrauch (l): "      .','.   sprintf("%8.2f", ReadingsVal("CN.Test","pulseTimeOverall","Fehler")/3600*2.12195121951);
# HTML / CSS zurückliefern
   return doMakeHtml($div_class, $header, @wert);
}

sub cntFmtTime($)
{
  my @t = localtime(shift);
  return sprintf("%02d:%02d:%02d", $t[2]-1, $t[1], $t[0]);
}

###################################################################################
# Create html-code
#
sub doMakeHtml($@){my ($div_class, $header, @line ) = @_;
#   my $htmlcode = '<div  class="'.$div_class."\"><table class="."block wide".">\n<caption><u><b>".$header."</u></b></caption>\n";
   my $htmlcode = "<tr><td><div class="."devType"."><b>".$header."</b></div></td></tr>\n<tr><td><div  class=".$div_class."\><table class="."block wide".">\n";
   foreach (@line) {
      my ($title, $value) = split (",",$_);
      my $cssTitle = $title;
      $cssTitle =~ s,[: -],,g;
      $htmlcode .= "<tr><td><span \"$cssTitle-title\">$title</span></td><td><span \"$cssTitle-value\">$value</span></td></tr>\n";
   }
   $htmlcode .= "</table></div>";
   return $htmlcode;
}

1;

#######################################
##############################################


sub sendSnapshot(@)
{
  my ($cam,$snapshots) = @_;
  my $storage = AttrVal($cam,"storage","");
  my $rcpt = 'abc@gmail.com';
  my $from = 'def@gmail.com';
  my $subj = "FHEM: Kamera $cam hat eine Bewegung aufgezeichnet";
  my $last = ReadingsTimestamp($cam,"last","");
  my $mess = "Kamera $cam hat eine Bewegung am $last aufgezeichnet:";<br>
  if(!-d $storage) {
    Log 1, "IPCAM $cam storagepath does not exists: $storage";
    return "storagepath for $cam does not exists: $storage";
  }
  if(!$last) {
    Log 1, "IPCAM $cam no snapshots available";
    return "no snapshots available for $cam";
  }<br>
  my $cmd  = "sendEmail -f $from -t $rcpt -u $subj -m $mess ";
     $cmd .= "-o message-content-type=text -o message-charset=utf-8 -a";
  for (my $s=1;$s<$snapshots+1;$s++) {
    $cmd .= " $storage/".ReadingsVal($cam,"snapshot$s","");
  }
  my $ret  = `$cmd`;
  $ret =~ s/[\r\n]//g;
  Log 4, "IPCAM sendSnapshot: $ret";
  return undef;
}<br>
1;



heikoh81

Bei mir leider auch das gleiche Problem und keine Lösung.

rbs

ich habe das selbe problem.
soll die Datei wirklich so angelegt werden?

habe beim anlegen der datei auch einen fehler:
syntax error at ./FHEM/99_ipcam_Utils.pm line 21, near ") {" Global symbol "$last" requires explicit package name at ./FHEM/99_ipcam_Utils.pm line 25. Global symbol "$cam" requires explicit package name at ./FHEM/99_ipcam_Utils.pm line 26. Global symbol "$cam" requires explicit package name at ./FHEM/99_ipcam_Utils.pm line 27. syntax error at ./FHEM/99_ipcam_Utils.pm line 29, near "my " Global symbol "$cmd" requires explicit package name at ./FHEM/99_ipcam_Utils.pm line 29. Global symbol "$cmd" requires explicit package name at ./FHEM/99_ipcam_Utils.pm line 30. Global symbol "$snapshots" requires explicit package name at ./FHEM/99_ipcam_Utils.pm line 31. Global symbol "$cmd" requires explicit package name at ./FHEM/99_ipcam_Utils.pm line 32. Global symbol "$storage" requires explicit package name at ./FHEM/99_ipcam_Utils.pm line 32. Global symbol "$cam" requires explicit package name at ./FHEM/99_ipcam_Utils.pm line 32. Global symbol "$cmd" requires explicit package name at ./FHEM/99_ipcam_Utils.pm line 34. syntax error at ./FHEM/99_ipcam_Utils.pm line 38, near "}" ./FHEM/99_ipcam_Utils.pm has too many errors.


Papaloewe

Nur geraten:
Ich finde das sieht komisch aus
}<br>

Versucht doch mal nur die geschweifte Klammer und lasst das <br> weg.