Socket
Socket
Sign inDemoInstall

exec-sh

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exec-sh

Execute shell command forwarding all stdio.


Version published
Weekly downloads
4.7M
decreased by-3.01%
Maintainers
1
Weekly downloads
 
Created

What is exec-sh?

The exec-sh npm package is a simple utility for executing shell commands in Node.js. It provides a straightforward API to run shell commands synchronously or asynchronously, with options to handle output and errors.

What are exec-sh's main functionalities?

Execute a command asynchronously

This feature allows you to execute a shell command asynchronously. The callback function handles any errors and provides the exit code if the command fails.

const execSh = require('exec-sh');
execSh('echo Hello World', function(err){
  if (err) {
    console.log('Exit code:', err.code);
    return;
  }
  console.log('Command executed successfully');
});

Execute a command synchronously

This feature allows you to execute a shell command synchronously. If the command fails, an error is thrown, and you can catch it to handle the exit code.

const execSh = require('exec-sh');
try {
  execSh.sync('echo Hello World');
  console.log('Command executed successfully');
} catch (err) {
  console.log('Exit code:', err.code);
}

Capture command output

This feature allows you to capture the standard output and standard error of the executed command. The callback function provides the stdout and stderr as arguments.

const execSh = require('exec-sh');
execSh('echo Hello World', true, function(err, stdout, stderr){
  if (err) {
    console.log('Exit code:', err.code);
    return;
  }
  console.log('stdout:', stdout);
  console.log('stderr:', stderr);
});

Other packages similar to exec-sh

Keywords

FAQs

Package last updated on 17 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc