Philip Nguyen Philip Nguyen - 1 year ago 112
Bash Question

Unix Bash script causing git clone to not work

I have a bash script ( where I perform a git clone.
Then, from that repository, I run a another script ( which runs fine.
I run just fine, but the git repo is non existant. Any folder just isn't there. If I run the git clone on the command line, it clones it just fine.
Why is my script no git cloning my repo correctly?

How I run the first script.

sudo bash

cd /home/ubuntu
git clone localfolder
#run script from the repo
sudo bash localfolder/

~ Some unrelated unix commands

Notes: I tried looking at the /home/ubuntu folder and could not find it. It's not a "hidden" file as well.

Answer Source

This could solve your problem replace your

git clone $folder
#run script from the repo
bash $folder/

if it does not work, it is maybe possible that you are not allowed to write on $home because of your current user permissions or because your fs is read-only You can check that by executing mount without option, it will list all mounted fs.

Another point, sudoing from inside a script is not recommended. Currently you are basically sudoing on a sudo. If you want to be sure the right user is executing your script, you better check the current id than doing nested sudo.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download