DeveloperBreeze

Execution Development Tutorials, Guides & Insights

Unlock 1+ expert-curated execution tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your execution skills on DeveloperBreeze.

Execute Shell Command using 'child_process' module

Code January 26, 2024
javascript

// 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);
});