Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP file not being executed from post-commit

Tags:

bash

php

svn

I have this in post-commit:

#!/bin/sh

REPOS="$1"
REV="$2"

/usr/bin/php /home/name/svn/scripts/post-commit.php $REPOS $REV

But whatever I do, post-commit.php isn't being executed, not even with a chmod a+rw on it. Also there is no output from exec.

What am I missing?

Update: removed exec > ./logs/log.txt from this example since it seems to confuse people.

like image 221
Gavin Hewitt Avatar asked Mar 31 '26 21:03

Gavin Hewitt


2 Answers

try:

#!/bin/sh
REPOS="$1"
REV="$2"

#debug:
echo "------------------------------"
date >> /tmp/debug.txt
echo "$@" >> /tmp/debug.txt
id >> /tmp/debug.txt
env >> /tmp/debug.txt

/usr/bin/php /home/name/svn/scripts/post-commit.php "$REPOS" "$REV" > /full/path/to/log.txt 2>&1

Also, verify that your post script works fine when executed by hand.

like image 128
Michał Šrajer Avatar answered Apr 03 '26 11:04

Michał Šrajer


exec replaces the current shell process, and doesn't start a new one. So after the exec command, your shell stops.

The purpose of your particular exec command eludes me by the way ... So just remove it and you should be fine.

like image 26
Martin Tournoij Avatar answered Apr 03 '26 12:04

Martin Tournoij