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, tools, and much more.