I am reading some commands from input and executing at run-time in my java program . If there is any syntax or semantic errors it will fail at run-time. Instead of that I want to fail early. So I want to validate commands before execution.
How can i do that?? Is there any simple way.
Ex:
grep -P -o "cpums=[^ ]+" | cut -f2 -d= | cut -f1 -d"]" | awk '{a+=$1;}
END {print a;}
Here the single quote (') is missed at the end of this command. It will fail at run-time in my java program. It would be great if it can fail early. So i just want to validate every command at beginning of my program.
I am looking for an optimal way.