DeveloperBreeze

Execute Shell Command using 'child_process' module

// Import 'child_process' module
const { exec } = require('child_process');

// Execute 'ls -l' command
exec('ls -l', (error, stdout, stderr) => {
  // Check for errors
  if (error) {
    console.error('Error:', error);
    return;
  }

  // Log the result
  console.log('Result:', stdout);
});

Continue Reading

Handpicked posts just for you — based on your current read.

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!