Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. wget lädt nur eine 0kb Datei aus Stream

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    wget lädt nur eine 0kb Datei aus Stream

    This topic has been deleted. Only users with topic management privileges can see it.
    • JohGre
      JohGre @David G. last edited by JohGre

      @David-G
      in meinen Scripts ist die Url immer in singleTicks eingeschlossen

      wget -O /media/meinBild.jpg '10.0.0.xx:xx/CGIProxy.fcgi?cmd=snapPicture2&usr=xxx&pwd=xxx'
      
      UncleSam David G. 2 Replies Last reply Reply Quote 0
      • UncleSam
        UncleSam Developer @JohGre last edited by

        @JohGre Ja, das dürfte es sein, denn der Befehl kommt ganz komisch rein - im Passwort sind wohl Steuerzeichen.

        1 Reply Last reply Reply Quote 0
        • David G.
          David G. @JohGre last edited by

          @JohGre @UncleSam

          Danke, hab ich mal getestet.
          Jetzt kommt

          Last login: Thu Nov 12 10:13:23 2020 from 192.168.99.55
          pi@iobroker:~ $ wget -v /opt/iobroker/snapshot/snapshoot.jpg 'http://192.168.xxxxx/snapshot.jpg?user=xxxx&pwd=xxxxx&strm=1'
          /opt/iobroker/snapshot/snapshoot.jpg: Schema fehlt.
          --2020-11-12 10:16:48--  http://192.168.xxxxx/snapshot.jpg?user=xxx&pwd=xxcc&strm=1
          Verbindungsaufbau zu 192.168.99.44:80 … verbunden.
          HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
          Länge: 28136 (27K) [image/jpeg]
          Wird in »snapshot.jpg?user=xxxx&pwd=xxxx&strm=1.3« gespeichert.
          
          snapshot.jpg?us 100%[======>]  27,48K  64,0KB/s    in 0,4s
          
          2020-11-12 10:16:49 (64,0 KB/s) - »snapshot.jpg?user=xxxx&pwd=xxxx&strm=1.3« gespeichert [28136/28136]
          
          BEENDET --2020-11-12 10:16:49--
          Verstrichene Zeit: 0,7s
          Geholt: 1 Dateien, 27K in 0,4s (64,0 KB/s)
          pi@iobroker:~ $
          

          Die Datei ist nochoch leer.

          JohGre AlCalzone 2 Replies Last reply Reply Quote 0
          • JohGre
            JohGre @David G. last edited by JohGre

            @David-G Versteh ich nicht hat doch ein Bild mit 27k geladen. Probiers mal mit

            sudo wget -v /opt/iobroker/snapshot/snapshoot.jpg 'http://192.168.xxxxx/snapshot.jpg?user=xxxx&pwd=xxxxx&strm=1'
            

            vielleicht liegst an Schreibrechten im Zielverzeichnis. Und ich habe -O anstatt -v im wget Aufruf

            David G. 1 Reply Last reply Reply Quote 0
            • David G.
              David G. @JohGre last edited by David G.

              @JohGre @UncleSam

              Ja,
              jetzt speichert er auch die Bilder. Sogar ohne sudo und aus Blockly heraus.

              Jedoch hat mir der Telegramadapter beim Senden einen Fehler ausgegeben.
              Darauf hin habe ich mir das Bild mal angeschaut.

              Man kann es nicht öffnen. Zumindest nicht unter Windows und Android.

              Im Browser hat man unter dem Link ein normales JPG was man speichern kann.

              1 Reply Last reply Reply Quote 0
              • arteck
                arteck Developer Most Active last edited by arteck

                sendImage();
                
                function sendImage() {
                
                    let bild = "/opt/iobroker/iobroker-data/bild.jpg";
                    
                    axios({
                        method: 'get',
                        url: 'http://192.168.xxxxx/snapshot.jpg?user=xxxx&pwd=xxxxx&strm=1',
                        responseType: 'stream'
                    })
                    .then(function (response) {
                        response.data.pipe(fs.createWriteStream(bild));
                        setTimeout(function() {
                        sendTo('telegram.0', {
                            text : bild, 
                            disable_notification:   true
                            });
                        }, 300);  
                    });
                }
                

                das ist was du suchst

                David G. AlCalzone 2 Replies Last reply Reply Quote 0
                • David G.
                  David G. @arteck last edited by David G.

                  @arteck

                  Kann ich das Script so wie es ist nehmen und nur die URL anpassen?

                  Welche Einheit hat der Timeout von 300 (Ist das einer?) ?
                  Benutze leider nur mit Blockly.

                  Kann ich das so in Blockly integrieren mit einem Trigger?

                  Wobei ich es trotzdem interessant finde, warum er das Bild nicht richtig speichert.

                  1 Reply Last reply Reply Quote 0
                  • AlCalzone
                    AlCalzone Developer @arteck last edited by

                    @arteck Wieso nicht warten bis der Stream fertig ist statt ein fixes (möglicherweise unnötig langes oder zu kurzes) Timeout?

                    arteck 1 Reply Last reply Reply Quote 0
                    • AlCalzone
                      AlCalzone Developer @David G. last edited by

                      @David-G sagte in wget lädt nur eine 0kb Datei aus Stream:

                      wget -v /opt/iobroker/snapshot/snapshoot.jpg 'http://192.168.xxxxx/snapshot.jpg?user=xxxx&pwd=xxxxx&strm=1'

                      Müsste der Befehl nicht

                      wget -v -O /opt/iobroker/snapshot/snapshoot.jpg 'http://192.168.xxxxx/snapshot.jpg?user=xxxx&pwd=xxxxx&strm=1'
                      

                      sein (also Ausgabe-Dateiname per -O angeben)?
                      ==> https://wiki.ubuntuusers.de/wget/

                      Obiger Befehl würde versuchen, /opt/iobroker/snapshot/snapshoot.jpg herunter zu laden, was keinen Sinn macht.

                      David G. 1 Reply Last reply Reply Quote 0
                      • David G.
                        David G. @AlCalzone last edited by

                        @AlCalzone

                        Ja, das srimmt.

                        Ist auch der letzte Stand. Nur eben mit einem Bild was man nicht öffnen kann.

                        sudo wget -o /opt/iobroker/snapshot/bild1.jpg 'http://192.168.xxxxx/snapshot.jpg?user=xxxx&pwd=xxxxx&strm=1'
                        
                        AlCalzone 1 Reply Last reply Reply Quote 0
                        • David G.
                          David G. last edited by David G.

                          @UncleSam @JohGre

                          Unter Windows konnte ich die Bilddateien jetzt öffnen.
                          WinSCP öffnet sie im Editor.

                          Ihr Inhalt ist:

                          --2020-11-12 11:18:57--  http://192.168.xx.xx/snapshot.jpg?user=xx&pwd=xxx&strm=1
                          Verbindungsaufbau zu 192.168.xx.xx:80 … verbunden.
                          HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
                          Länge: 26564 (26K) [image/jpeg]
                          snapshot.jpg?user=xxx&pwd=xxxx&strm=1: Keine Berechtigung
                          
                          Schreiben nach »snapshot.jpg?user=xxxx&pwd=xxxxx&strm=1« nicht möglich (Keine Berechtigung).
                          
                          
                          1 Reply Last reply Reply Quote 0
                          • AlCalzone
                            AlCalzone Developer @David G. last edited by AlCalzone

                            @David-G großes O, nicht kleines o. Und bitte lass das sudo weg, das verhaut dir nur die Berechtigungen.

                            David G. 1 Reply Last reply Reply Quote 0
                            • David G.
                              David G. @AlCalzone last edited by

                              @AlCalzone

                              Danke, das war es.
                              Das sudo hatte ich schon weg.
                              Das kleine -o war das Problem.

                              Hab grad erfolgreich das Bild per Telegram bekommen.

                              L 1 Reply Last reply Reply Quote 0
                              • L
                                LJSven @David G. last edited by

                                Bei mir geht es auch um wget, allerdings bekomme ich die Datei einfach nicht auf meinen USB Stick von der FritzBox gespeichert. Im User "pi" ist der Stick unter /media/fritzbox-usb eingebunden. Ich kann auch von der Konsole zugreifen. Führe ich jetzt z.B. den Befehl

                                wget --output-document /media/fritzbox-usb/snapshot.png  'http://192.168.178.225/capture'
                                

                                aus, wird die Datei nicht gespeichert. Wenn ich das Bild in den /tmp Ordner via

                                wget --output-document /tmp/snapshot.png  'http://192.168.178.225/capture'
                                

                                speichere, geht es ohne Probleme. Was mache ich falsch?

                                Von der Konsole kann ich auf den Mountpunkt zugreifen.

                                1 Reply Last reply Reply Quote 0
                                • arteck
                                  arteck Developer Most Active @AlCalzone last edited by arteck

                                  @AlCalzone gute frage..... 😊

                                  let axios   = require('axios');
                                  var fs      = require('fs');
                                  let bild1 = "/opt/iobroker/iobroker-data/bild.jpg";
                                  
                                  
                                  sendImage1();
                                  
                                  async function sendImage1() {
                                      const writer = fs.createWriteStream(bild);
                                      const response = await axios({
                                          url: 'http://192.168.xxxxx/snapshot.jpg?user=xxxx&pwd=xxxxx&strm=1',
                                          method: 'get',        
                                          responseType: 'stream'
                                      })
                                      
                                      response.data.pipe(writer);
                                  
                                      return new Promise((resolve, reject) => {
                                          writer.on('finish', resolve => {
                                              sendTo('telegram.0', {
                                                  text : bild, 
                                                  disable_notification:   true
                                              });
                                          })        
                                    })   
                                  }
                                  
                                  vowill 1 Reply Last reply Reply Quote 1
                                  • vowill
                                    vowill @arteck last edited by vowill

                                    @david-g
                                    Nachdem mich das Thema mit der leeren Datei nach einem wget nun ebenfalls 2 Tage beschäftigt hat, habe ich in meinem Fall die folgende Ursache festgestellt:
                                    Die http-Quelle, von der ich das Bild hole (bei mir Motioneye), hat die gleiche IP-Adresse wie der ioBroker, der das Bild abholt. Beide laufen in einem Docker-Container des Host-Rechners (bei mir ein QNAP-NAS) - und in dieser Konfiguration kann es passieren, dass keine Kommunikation zwischen den beiden Docker-Instanzen möglich ist. Dies ist z. B. in den 'Docker Docs' (siehe hier) beschrieben.
                                    Ich habe dementsprechend Motioneye neu installiert mit der Netzwerkeinstellung "Bridge". Damit erhält Motioneye eine eigene IP-Adresse, und der Zugriff vom ioBroker klappt dann reibungslos 😃

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post

                                    Support us

                                    ioBroker
                                    Community Adapters
                                    Donate

                                    899
                                    Online

                                    32.0k
                                    Users

                                    80.5k
                                    Topics

                                    1.3m
                                    Posts

                                    blockly multimedia security
                                    7
                                    19
                                    720
                                    Loading More Posts
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    Community
                                    Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                    The ioBroker Community 2014-2023
                                    logo