Theory5 / BroScriptStuff

Bro Script Default Repository for Theory
3 stars 0 forks source link

Testing for a dir #1

Open secure411dotorg opened 10 years ago

secure411dotorg commented 10 years ago

https://github.com/Theory5/BroScriptStuff/blob/master/fullinst/tminst.sh#L17 and #L23 suggest that some unknown failures will occur if the path of bro is different than expected.

You can test for the existence of a file in the path you expect like:

if [ -f "/foo/bar/baz" ];then echo "To be!"; else echo "It is not to be";exit 1;fi

or similar. Be sure to always use SPACES inside the square brackets and quote your strings and vars inside the square brackets.

So you could exit the script with an echo to the user saying something like "This script expects bro (or whatever it is you expect) to be located at whatever path, exiting to avoid whatever consequence" or if the item is found where it should be then echo path bro or whatever found at whatever path, to reassure the user that things are going well.