繁体   English   中英

Rails:如何使用Bash脚本运行“ rake”命令?

[英]Rails: How to run “rake” commands using Bash script?

我创建了带有以下内容的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

在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! ***"

这会给您进一步的信息吗?

要运行该命令,您需要输入:

./reset_db.sh

关于rake命令,您是否在应该启动rake的文件夹中?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM