Package Information
Documentation
n8n-nodes-command-executor
This is an n8n community node that allows you to execute shell commands on self-hosted n8n instances.
n8n is a fair-code licensed workflow automation platform.
⚠️ Security Warning
IMPORTANT: This node executes arbitrary commands on your server. It should ONLY be used on self-hosted n8n instances that you control. Never use this node if you don't understand the security implications.
- Commands run with the same permissions as your n8n process
- Malicious commands could damage your system or compromise security
- Always validate and sanitize inputs when using generic command mode
- Consider using templates for common operations to reduce risk
Installation
Follow the installation guide in the n8n community nodes documentation.
NPM
npm install n8n-nodes-command-executor
Manual Installation (Development)
- Clone this repository
- Run
npm installto install dependencies - Run
npm run buildto build the node - Copy the built files to your n8n custom nodes directory
Operations
The Command Executor node supports two modes:
Generic Command Mode
Execute any shell command you specify. This mode gives you complete flexibility but requires careful attention to security.
Example:
echo "Hello from n8n!"
Template Mode
Use pre-configured command templates with safe, parameterized inputs. This is the recommended mode for most use cases.
Available Templates
| Template | Description | Parameters |
|---|---|---|
| System Information | Get OS info, disk usage, and memory | None |
| List Files | List files in a directory | Path, Options |
| Read File | Read file contents | File Path |
| Find Files | Find files matching a pattern | Search Path, Pattern |
| Process List | List running processes | Filter (optional) |
| Network Ping | Ping a host | Host, Count |
| HTTP Request (curl) | Make HTTP requests with curl | URL, Options |
| Disk Usage | Show disk usage for a path | Path |
| Execute Python Code | Run Python code or script files | Execution Mode, Interpreter, Code/File Path, Arguments |
| Execute Node.js Code | Run JavaScript code or script files | Execution Mode, Code/File Path, Arguments |
Configuration
Common Options
- Working Directory: Set the working directory for command execution
- Timeout: Maximum execution time in seconds (1-300, default: 30)
- Environment Variables: Add custom environment variables for your command
- Continue on Error: If enabled, the workflow continues even if the command fails
Output
The node returns the following data for each execution:
{
"command": "echo 'test'",
"exitCode": 0,
"stdout": "test\n",
"stderr": "",
"executionTimeMs": 45,
"success": true
}
Usage Examples
Example 1: System Information
Use the "System Information" template to get details about your server:
- Add Command Executor node
- Select Mode: "Template"
- Select Template: "System Information"
- Run the workflow
Example 2: List Files
List all files in a directory with details:
- Add Command Executor node
- Select Mode: "Template"
- Select Template: "List Files"
- Path:
/var/log - Options: "Long format with hidden files (-lah)"
Example 3: Generic Command
Execute a custom command:
- Add Command Executor node
- Select Mode: "Generic Command"
- Command:
df -h | grep /dev/ - Run the workflow
Example 4: Backup Database
Use generic mode to backup a database:
mysqldump -u root -p'password' mydb > /backups/mydb_$(date +%Y%m%d).sql
⚠️ Security Note: Never hardcode sensitive credentials. Use environment variables or n8n credentials instead.
Example 5: Execute Python Code
Run Python code inline:
- Add Command Executor node
- Select Mode: "Template"
- Select Template: "Execute Python Code"
- Execution Mode: "Inline Code"
- Python Interpreter: "Python 3"
- Code:
import sys; print(f"Python {sys.version}") - Run the workflow
Or execute a Python script file:
- Execution Mode: "File Path"
- File Path:
/path/to/script.py - Arguments:
--arg1 value1
Example 6: Execute Node.js Code
Run JavaScript code inline:
- Add Command Executor node
- Select Mode: "Template"
- Select Template: "Execute Node.js Code"
- Execution Mode: "Inline Code"
- Code:
console.log(process.version); console.log("Hello from Node!") - Run the workflow
Or execute a JavaScript file:
- Execution Mode: "File Path"
- File Path:
/path/to/script.js - Arguments:
--experimental-modules
Development
Setup
git clone https://github.com/your-repo/n8n-nodes-command-executor.git
cd n8n-nodes-command-executor
npm install
Build
npm run build
Run in Development Mode
npm run dev
This will start n8n with your node loaded and watch for changes.
Lint
npm run lint
npm run lint:fix
Compatibility
- Tested with n8n v1.0+
- Compatible with Node.js v20+
Resources
License
Version History
0.1.0
- Initial release
- Generic command execution
- 10 pre-configured templates (including Python and Node.js code execution)
- Environment variable support
- Configurable timeouts and working directory
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Support
If you have any issues or questions, please open an issue on GitHub or ask in the n8n community forum.
Disclaimer
This node is provided as-is with no warranties. Use at your own risk. The authors are not responsible for any damage or security issues that may arise from using this node.