# shell script calling git fails when called from scheduler

3 messages from 2011-03-25 to 2011-03-25. Participants: Markus Heller, Matt Harrison.
Thread: https://gitlist.dev/t/26866

## Markus Heller, 2011-03-25 22:04

Subject: shell script calling git fails when called from scheduler
Message-ID: <0v62r6q2lm.fsf@gmail.com>
URL: https://gitlist.dev/e/0v62r6q2lm.fsf%40gmail.com

```
Hi all,

I have the following batch shell script (org-git-synch.bat):

@ECHO OFF

REM get date and time
for /f "delims=" %%a in ('date/t') do @set mydate=%%a
for /f "delims=" %%a in ('time/t') do @set mytime=%%a
set fvar=%mydate%%mytime%

REM add all new files
call git add .
call git commit -a -m "Automated commit by org-git-sync.bat on %fvar%"

The script resides in h:/org/; and I have a working git repository in
this directory (in h:/org/.git).

I can run the script from the command line no problem, but when I try to
run it from the Windoze scheduler, all I get is a cmd window saying:

fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git

I did re-initialize the repository, but that didn't matter, since git
status and everything else works fine from the command line.  I'm on Win
7 Pro 64 bit SP 1.

Any ideas?

Thanks and Cheers
Markus

```

## Matt Harrison, 2011-03-25 22:19

Subject: Re: shell script calling git fails when called from scheduler
Message-ID: <20110325221914.GA11156@genestate.com>
URL: https://gitlist.dev/e/20110325221914.GA11156%40genestate.com
In-Reply-To: <0v62r6q2lm.fsf@gmail.com>

```
On Fri, Mar 25, 2011 at 03:04:05PM -0700, Markus Heller wrote:
> Hi all,
> 
> I have the following batch shell script (org-git-synch.bat):
> 
> @ECHO OFF
> 
> REM get date and time
> for /f "delims=" %%a in ('date/t') do @set mydate=%%a
> for /f "delims=" %%a in ('time/t') do @set mytime=%%a
> set fvar=%mydate%%mytime%
> 
> REM add all new files
> call git add .
> call git commit -a -m "Automated commit by org-git-sync.bat on %fvar%"
> 
> The script resides in h:/org/; and I have a working git repository in
> this directory (in h:/org/.git).
> 
> I can run the script from the command line no problem, but when I try to
> run it from the Windoze scheduler, all I get is a cmd window saying:
> 
> fatal: not a git repository (or any of the parent directories): .git
> fatal: not a git repository (or any of the parent directories): .git
> 
> I did re-initialize the repository, but that didn't matter, since git
> status and everything else works fine from the command line.  I'm on Win
> 7 Pro 64 bit SP 1.
> 
> Any ideas?
> 
> Thanks and Cheers
> Markus

At a guess (I dont use the windows scheduler), the working directory of the batch file
is not being set to h:/org

I dont know if there is a way to tell the windows scheduler what the working directory
should be, so maybe try cd'ing to h:/org at the start of your script?

HTH

Matt

```

## Markus Heller, 2011-03-25 23:03

Subject: Re: shell script calling git fails when called from scheduler
Message-ID: <0v1v1upzui.fsf@gmail.com>
URL: https://gitlist.dev/e/0v1v1upzui.fsf%40gmail.com
In-Reply-To: <20110325221914.GA11156@genestate.com>

```
Matt Harrison <iwasinnamuknow@genestate.com> writes:

> On Fri, Mar 25, 2011 at 03:04:05PM -0700, Markus Heller wrote:
>> Hi all,
>> 
>> I have the following batch shell script (org-git-synch.bat):
>> 
>> @ECHO OFF
>> 
>> REM get date and time
>> for /f "delims=" %%a in ('date/t') do @set mydate=%%a
>> for /f "delims=" %%a in ('time/t') do @set mytime=%%a
>> set fvar=%mydate%%mytime%
>> 
>> REM add all new files
>> call git add .
>> call git commit -a -m "Automated commit by org-git-sync.bat on %fvar%"
>> 
>> The script resides in h:/org/; and I have a working git repository in
>> this directory (in h:/org/.git).
>> 
>> I can run the script from the command line no problem, but when I try to
>> run it from the Windoze scheduler, all I get is a cmd window saying:
>> 
>> fatal: not a git repository (or any of the parent directories): .git
>> fatal: not a git repository (or any of the parent directories): .git
>> 
>> I did re-initialize the repository, but that didn't matter, since git
>> status and everything else works fine from the command line.  I'm on Win
>> 7 Pro 64 bit SP 1.
>> 
>> Any ideas?
>> 
>> Thanks and Cheers
>> Markus
>
> At a guess (I dont use the windows scheduler), the working directory of the batch file
> is not being set to h:/org
>
> I dont know if there is a way to tell the windows scheduler what the working directory
> should be, so maybe try cd'ing to h:/org at the start of your script?

Thanks Matt,

this was the problem.  U can specify the directory where the script
should be run in the scheduler.

Cheers
Markus

```
