Score:0

No such file or directory in sh file running

in flag

It may be duplicate because there is some similar question but I am not able to fix it, that's why I ask again with my code.

My sh have these code:

cd /home/domain.com/data/domain-statistics
git fetch origin
git merge origin/master
git add --all
git add .
git commit -am "File generated and updated on `date`"
git push origin master

when i run it as:

-bash-4.2$ sh /home/domain.com/data/crons/push.sh

Then its always show as:

-bash-4.2$ sh /home/domain.com/data/crons/push.sh
/home/domain.com/data/crons/push.sh: line 1: cd: /home/domain.com/data: No such file or directory
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git

please help me.

in flag
@Martin git is not working because cd /home/domain.com/data/domain-statistics is not working
Martin avatar
kz flag
just saw that, too - I missed that. But why do you assume that this directory should exist, and should contain a git repo ?
in flag
these all codes working if i run by direct in terminal
Martin avatar
kz flag
check for typos inside the directory path ... I can't think of anything else which might be wrong in this case
Score:0
kp flag

I have no reputation to comment, so I write it as an answer. Have you tried the cd command using relative path instead? If I am not wrong this would be:

cd ../domain-statistics
Score:0
cn flag

these all codes working if i run by direct in terminal

So if you're not running in your terminal, then how is it being run?

If it's being run under some other user, then that user may well not have access to that directory (or one or more of its parent directories).

Examine the permissions on each directory in the path /home/domain.com/data.

in flag
You can see my question how j am running it by sh file, I am using by sh file because I need to run it every 10 minutes. So I am using by cron job.
Phill  W. avatar
cn flag
A cron job for /which/ user? Every user, not just root, can have their own cron jobs and each will run in the security context of the owning user. Also, cron jobs notoriously run without the usual profile settings for the user account. Assuming that this is for the same user and cron is, therefore, a Red Herring - You did not address my question about file system permissions.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.