This three line bash script that I wrote,
#! /bin/bash
cd /home/me/path/to/project
source ../../bin/activate
is located in the directory '~/scripts'. I wrote it in order to make it faster to move to a subdirectory for a project that has a long name. This project is written in Python so the second line
source ../../bin/activate
activates the virtualenv where the depencies are installed. However, when I run,
bash script.sh
in '~/scripts' nothing happens. I have run the code manually and verified that it works correctly. Additionally, today is the first time I have observed this behavior. Am I missing something obvious? Why doesn't this work? The only related action I have taken between the last time I ran the script and now was to copy the directory housing the entire project onto a backup hard drive. I am on Ubuntu 18.04.5 LTS
source ../../bin/activatesupposed to do?). Any error messages? – Kamil Maciorowski Aug 24 '21 at 04:12. script.sh(equivalent tosource script.sh) instead ofbash script.sh. This is sourcing vs executing the linked duplicate talks about. To have the question reopened you need to clearly state sourcing the script in question does not work. – Kamil Maciorowski Aug 24 '21 at 04:22#! /bin/bashin your case) is irrelevant when you source the script (. script.sh) or execute an interpreter explicitly with the script as an argument (bash script.sh). It's only relevant when you run the script directly (./script.sh). Running the script directly is not what you want here. I'm only pointing out the shebang is irrelevant in your use case. When you source a script, the shebang in it is only a comment. – Kamil Maciorowski Aug 24 '21 at 04:33