1

I created reset_db.sh (with chmod +x) with the following content:

#!/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! ***"

However, when I run:

bash reset_db.sh

I see:

*** Deleting the database ***
*** Creating the database ***
*** Migrating the database ***
*** Seeding the database ***
*** Done! ***

but the rake commands were not executed.

Any ideas why ?

Bonus question:

What should I do in order to be able to run reset_db.sh rather than bash reset_db.sh ?

2 Answers 2

5

Add set -x at the top of your bash script for more verbose output.

#!/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! ***"

Does that give you any further information?

Sign up to request clarification or add additional context in comments.

Comments

2

to run the command you need to type:

./reset_db.sh

Regarding the rake command, are you in the folder where the rake should be launched?

2 Comments

I think Matteo's on to something: I can't duplicate this issue on my local project. Make sure the file is in the same location as the project's Rakefile.
Thanks! The problem was totally different from what I thought... After running dos2unix on reset_db.sh, it started to work :) Thanks anyway for your time!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.