$command=htmlspecialchars($command); echo "$command <br>"; replace with $commandDisplay = htmlspecialchars($command); echo "$commandDisplay <br>"; (You were escaping the characters: " < > which doesn't work when you try to execute them with the exec() function.)