you might want to sanitize a little bit removing ",(,`,; and so on from word
you might want to check for execution instead of existance (-f)
run the script, see what processes are started with ps?
Run the script in an isolated environment ? A virtual machine ?
carlocci & moljac024:
Not an option. The script can take many different routes according to a variety of parameters. Checking the processes is not good either because a process can finish really fast, some things are just sh *functions* etc. I need to do this because I'm refactoring some code ;-)
That said, you can get an approximation by writing a parser. Parsers are hard. Smart programmers use a parser generator like bison or ANTLR to abstract away much of the complexity, but it's still sort of a pain in the butt the first time or two.
If you don't want to write a parser, a very approximate answer can be found by splitting each line by whitespace and returning the first word. Then finding other places commands can hide, like after semicolons, backticks, "$(", etc, but not when quoted. At this point, you will have written a very shoddy parser and taken longer at it than you would have if you'd bothered to learn bison or ANTLR.
]]>Does anyone know if there is a tool/script for this somewhere?
Thanks.
]]>