我使用以下内容创建了 reset_db.sh (包含chmod +x
):
#!/bin/bash
echo "*** Deleting the database ***"
rake db:drop --trace
echo "*** Creating the database ***"
rake db:create --trace
echo "*** Migrating the database ***"
rake db:migrate --trace
echo "*** Seeding the database ***"
rake db:seed --trace
echo "*** Done! ***"
然而,当我跑步时:
bash reset_db.sh
我明白了:
*** Deleting the database ***
*** Creating the database ***
*** Migrating the database ***
*** Seeding the database ***
*** Done! ***
但rake
命令未执行。
任何想法为什么?
加分问题:
我应该怎么做才能运行reset_db.sh
而不是bash reset_db.sh
?
答案 0 :(得分:4)
在bash脚本的顶部添加set -x
以获得更详细的输出。
#!/bin/bash
set -x
echo "*** Deleting the database ***"
rake db:drop --trace
echo "*** Creating the database ***"
rake db:create --trace
echo "*** Migrating the database ***"
rake db:migrate --trace
echo "*** Seeding the database ***"
rake db:seed --trace
echo "*** Done! ***"
这能为您提供更多信息吗?
答案 1 :(得分:2)
运行您需要输入的命令:
./reset_db.sh
关于rake命令,你是否在应该启动rake的文件夹中?