Discovery Script Fails with "Bad Substitution" Shell Error Issue A Discovery probe script fails with a “Bad substitution” shell error and a non-zero exit status. Symptoms /tmp/<script>: line <N>: Bad substitution Exit status: 2 Release All supported releases — this is shell/OS-level behavior, not version-specific. Cause Generic shell error, not ServiceNow-specific: the script uses Bash-only parameter expansion (e.g. substring or pattern substitution) Resolution 1. Confirm which shell ran the script (check if /bin/sh is linked to bash or dash). Related Links For Outbound REST Message-specific cases, see the related KB below. Outbound REST web service — Product Documentation Outbound REST message substitution escaping (KB0692465) Bash “Bad substitution” error explained (Stack Overflow)