Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. sshpass ssh - Befehl output kein result

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    sshpass ssh - Befehl output kein result

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MCU last edited by

      Wenn man den sshpass Befehl in der Console eingibt bekommt man ein Ergebnis.

      debug1: Sending command: sudo iwlist scan
      lo        Interface doesn't support scanning.
      
      eth0      Interface doesn't support scanning.
      
      wlan0     Scan completed :
      
      

      Ich erhalte aber kein Ergebnis, wenn ich den Exec Befehl nutze.

      exec('sshpass -p test ssh  pi@192.168.178.70 "sudo iwlist scan"', async function (error, result, stderr) {
          
          timeout = setTimeout(async function () {
          console.log(result);
          
        }, 3000);
      });
      
      

      Solche Dinge wie Umleitung habe ich schon probiert.

      "sudo iwlist scan 2>&1"
      "sudo iwlist scan -o output"
      

      Hat jemand eine Idee?

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

        @mcu Ich empfehle dir, direkt ein Node-Paket wie https://www.npmjs.com/package/node-ssh einzusetzen, statt einen Umweg über exec und die Shell zu gehen.

        M 1 Reply Last reply Reply Quote 0
        • M
          MCU @AlCalzone last edited by MCU

          @alcalzone

          const {NodeSSH} = require('node-ssh');
           
          const ssh = new NodeSSH();
           
          ssh.connect({
            host: '192.168.178.70',
            username: 'pi',
            password: 'test'
          });
          
          ssh.execCommand('sudo iwlist scan').then(function(result) {
              console.log('STDOUT: ' + result.stdout)
              console.log('STDERR: ' + result.stderr)
            });
          
          

          So bekomme ich auch keine Ausgabe.

          Im Scripte meldet er einen Fehler

          Cannot find module 'node-ssh' or its corresponding type declarations.(2307)
          

          51197a63-2703-4bee-9db9-5c02295b1408-image.png

          Versuch direkt zu installieren:

          sudo apt install node-ssh
          Paketlisten werden gelesen... Fertig
          Abhängigkeitsbaum wird aufgebaut.
          Statusinformationen werden eingelesen.... Fertig
          E: Paket node-ssh kann nicht gefunden werden.
          
          

          Installation gefunden

          sudo npm i node-ssh
          

          javascript-Instanz neugstartet, bringt aber auch keine Veränderung.

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

            @mcu sagte in sshpass ssh - Befehl output kein result:

            Cannot find module 'node-ssh' or its corresponding type declarations.(2307)

            Kannst du ignorieren. Das heißt im Endeffekt nur, dass der Editor dir keine Syntaxhilfe geben kann.

            Oder wenn du die Typdefinitionen wirklich willst, da zusätzlich eintragen:
            8ee697b9-6274-4ded-87e6-c72c4b807093-grafik.png
            Eventuell musst du auch noch unter zusätzliche Module @types/node-ssh installieren (falls es das gibt).

            M 1 Reply Last reply Reply Quote 0
            • M
              MCU @AlCalzone last edited by

              @alcalzone sagte in sshpass ssh - Befehl output kein result:

              42cf92dc-df13-4b39-a749-b70434c689e8-image.png

              So?

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

                @mcu Sieht richtig aus - bin mir aber nicht 100% sicher, ob das funktioniert.

                FYI, fs und readline sind Kern-Module, die musst du da nicht extra eintragen.

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

                Support us

                ioBroker
                Community Adapters
                Donate

                748
                Online

                31.8k
                Users

                80.0k
                Topics

                1.3m
                Posts

                communication javascript
                2
                6
                198
                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