keecode logokeecode
126

Cannot Execute

Command cannot execute

Bash

Exit Code Information

Exit Code

126

Name

Cannot Execute

Category

Bash

Usage Context

Permission problem or command is not an executable

Common Usage

Bash Script

#!/bin/bash

if [ condition ]; then
  echo "Cannot Execute"
  exit 126
fi

Check Exit Code

./script.sh
echo $?  # Prints the exit code

# Check if exit code matches
if [ $? -eq 126 ]; then
  echo "Cannot Execute"
fi

Node.js/JavaScript

// Exit with code 126
process.exit(126);

// Or throw error that results in exit code
if (error) {
  console.error('Cannot Execute');
  process.exit(126);
}

Python

import sys

# Exit with code 126
if error:
    print("Cannot Execute")
    sys.exit(126)