I want to make a file which will run 2 command.

One will activate a virtual enviroment and after that, second command will run a server.

My file is called "runserver" and it looks like these:

echo "Activating virtual enviroment"
source odoo-venv/bin/activate
echo "Running Odoo server"
./odoo12/odoo-bin --config=/etc/odoo12.conf

When I run this file with

sh runserver

It show the following error:

Activating virtual enviroment...
runserver: 3: source: not found
Running Odoo server...

It seems that my bash file is not recognizing the source command, how can I fix this?

  • 2
    source is a non-portable alias to .
    – gronostaj
    Commented Sep 7, 2020 at 11:01
  • 10
    Why are you running your script with sh runserver and not ./runserver? Commented Sep 7, 2020 at 11:49
  • 1
    @Colin'tHart Perhaps OP has not made it executable? How do I run .sh scripts?
    – Melebius
    Commented Sep 8, 2020 at 11:15

1 Answer 1


sh doesn't run your script in bash but in dash which doesn't support source. Use . instead:

. odoo-venv/bin/activate

or run the script with bash:

/bin/bash runserver

See also a similar question on StackOverflow.

  • or sh -c ./runserver
    – user986805
    Commented Sep 7, 2020 at 6:39
  • 8
    @bac0n: Calling one shell to call another shell? Possible but not quite efficient.
    – choroba
    Commented Sep 7, 2020 at 13:12
  • 13
    Or just ./runserver. Commented Sep 7, 2020 at 17:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .