Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8641827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:37:48+00:00 2026-06-12T11:37:48+00:00

I have two remote servers that need to have a certain codebase in sync.

  • 0

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`, "\n");
$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!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:37:49+00:00Added an answer on June 12, 2026 at 11:37 am

    which hg will only work if hg is already in your path, otherwise it will return the empty string.

    Obviously this is not what you want, since if it were already in your path, you could just use hg.

    If you’re using many machines with different configs, you could just create a bin directory in your home directory, add it to your path and make links to the commands you need in that directory. That will allow you to use the same commands on all machines.

    For PHP, you’d need to put it in a directory accessible to the web server (but preferably outside the document root), besides that, you can use the same technique there by giving an absolute path to the common directory where you created your links.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two servers on PHP that need to communicate, calling remote methods of
Suppose you have two linked servers called Local and Remote respectively. Is there a
I have an activity which needs to make two remote server calls. The first
I have an android app, that connectos to the remote database with PHP+json but
I have two git repositories: report.git (Master on remote location) cloned.git (Local) I lost
I have two different list types. I need to remove the elements from list1
I have two arrays. I'd like to merge them into one, but remove the
I have two servers running on redhat and debian. I am using a perl
I have a simple html page that only uses PHP in two places <?php
I have two combobox in my form, using a mysql connection to a remote

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.