Gavin Hewitt
Gavin Hewitt

Reputation: 155

PHP file not being executed from post-commit

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.

Upvotes: 3

Views: 452

Answers (3)

Michał Šrajer
Michał Šrajer

Reputation: 31182

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.

Upvotes: 1

shiying yu
shiying yu

Reputation: 103

you'd better to exec a 'cd' first, to a directory where you really want the shell to execute. i'm not sure the path SVN will have when running this, but of course your script have potential privilege problems

Upvotes: 0

Martin Tournoij
Martin Tournoij

Reputation: 27822

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.

Upvotes: 1

Related Questions