• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Parsing stdout into a module for display

Scheduled Pinned Locked Moved Requests
3 Posts 2 Posters 1.8k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    darrene
    last edited by Nov 4, 2016, 8:06 PM

    Is anyone able to provide an example of a simple module that can parse/display a printf output on the mirror? I’m trying to do this but really struggling to understand how to. I can use fprintf to get to a file but that’s not much help to me either.

    Ideally I would like to printf a value that will then be displayed in my module on the mirror…

    S 1 Reply Last reply Nov 4, 2016, 10:05 PM Reply Quote 0
    • S Offline
      strawberry 3.141 Project Sponsor Module Developer @darrene
      last edited by Nov 4, 2016, 10:05 PM

      @darrene in the node_helper you can do something like that

      const spawn = require('child_process').spawn;
      const ls = spawn('ls', ['-lh', '/usr']);
      
      ls.stdout.on('data', (data) => {
        console.log(`stdout: ${data}`);
      });
      
      ls.stderr.on('data', (data) => {
        console.log(`stderr: ${data}`);
      });
      
      ls.on('close', (code) => {
        console.log(`child process exited with code ${code}`);
      });
      

      https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options

      Please create a github issue if you need help, so I can keep track

      D 1 Reply Last reply Nov 5, 2016, 1:29 PM Reply Quote 0
      • D Offline
        darrene @strawberry 3.141
        last edited by Nov 5, 2016, 1:29 PM

        Thanks so much @strawberry-3.141, that’s just what I needed to set me in the right direction. I’ll do a bit of reading and follow this approach,. I’ll be sure to post how I get on :)

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          1/3
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy