Add a code checking about file or not to the rails db command

Fix a problem using directory name as command wrongly when there is a same name directory with executable file.