Why do I get an error when commands stored in the variable is being executed?
Issue
- Why do I get an error when commands stored in the variable are being executed?
[example.sh]
#!/bin/sh
CMDSTR=$*
$CMDSTR
exit 0
Example Output:
# ./example.sh "( cd /tmp ; pwd ; ls -la )"
./example.sh: line 4: (: command not found
Environment
- Red Hat Enterprise Linux All
- Shell
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
