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 8128275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:49:33+00:00 2026-06-06T07:49:33+00:00

I am trying to setup a web-based portal through which we can checkout different

  • 0

I am trying to setup a web-based portal through which we can checkout different branches of our Git repository through a simple click on a back-end panel.

So currently, I have /var/www/devportal which contains index.php, status.sh and checkout.sh

In index.php I do the following:

$repo = $_GET['repo'];
$command = 'sh status.sh ' . $repo;
$output = exec($command);
echo "<pre>$output</pre>";

The contents of status.sh are:

#!/bin/bash -e
if [ $# -ne 1 ]
then
    echo "Usage: `basename $0` <repo name>"
    exit 1
fi
cd /var/www/$1
git status

And this works just fine. The output echoed in PHP shows me the status of the current branch within /var/www/proj.

Now when I try to do the same thing (passing 2 parms this time with the second one being the name of the branch to checkout) with checkout.sh, who’se contents are:

#!/bin/bash -e
if [ $# -ne 2 ]
then
    echo "Usage: `basename $0` <repo name> <branch name>"
    exit 1
fi
cd /var/www/$1
git checkout $2

It doesn’t work. Not only does it not work, I don’t get diddly squat for an error message. There is no output. I know that the checkout.sh script works fine because when I echo the command that is being sent via PHP’s exec command, copy that exact thing and run it via terminal logged in as root, it works just fine, does the checkout and returns the name of the newly activated branch.

Any tips on this would be greatly appreciated. My box is pretty standard, Ubuntu 10.04 and running Apache2.

Thanks!

  • 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-06T07:49:34+00:00Added an answer on June 6, 2026 at 7:49 am

    exec fills $output with your command standart output, to show error (if any) add “2>&1” at the end of your command.

    exec can also tell you the return value, try:

    $output = exec($command, $array_output, $ret_val);
    var_dump($ret_val);
    echo "<pre>$output</pre>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to setup git for our web development team unsuccessfully. Some
I'm trying to setup a Spring 3 Web MVC project, using the @Controller, annotation-based
I'm trying to setup a new web-application for learning purposes using the newest technologies:
I am trying to setup a content query web part in MOSS that will
I am trying to setup my linode account to serve a zend framework web
New to wordpress and web design in general. I'm trying to setup a website
When trying to run an Eclipse Dynamic Web Project under a Tomcat setup using
I am trying to set up a web page where trusted users can upload
I'm using Spring 3, and trying to set up a simple web-app using annotations
I an trying to setup Forms Based Authentication using ASPNetSQLMembershipProvider. In 2010 Beta 2,

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.