I have two remote servers that need to have a certain codebase in sync. I have it all set up on the first, but while setting it up on the second, I ran into a problem:
They don't have hg
installed in the same location. I can't just run hg <command>
because it returns the error:
sh: hg: command not found
So I had been using the full path, but that won't work with two separate hg
locations.
I thought it would be clever to run which hg
and use the path from the response, so here's the new code:
$hg = trim(`which hg`, "
");
$output = `{$hg} pull -u`
But $hg
is NULL
, so that doesn't work! I can ssh into the 2nd server and see that which hg
definitely does work. I even appended 2>> path/to/log
to see if there were any errors with the which
command, but there was not. I made sure it was writing to the log, so it wasn't related to that.
I am not running in safe mode, and I am definitely allowed to run shell_exec
because other commands work.
I know I could just create a symlink so they both had the same path and just hardcode the path, but it's driving me crazy why shell_exec('which hg')
isn't working!!!