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

  • Home
  • SEARCH
  • 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 8149089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:46:43+00:00 2026-06-06T14:46:43+00:00

I have a bash script which need to execute some php scripts and to

  • 0

I have a bash script which need to execute some php scripts and to get back the results e.g

#!/bin/bash
/usr/bin/php -f $HOME/lib/get_fifobuild.php

The script get_fifobuild.php returns an integer which I need to assign into a bash variable. I ll appreciate if someone help me out.

thanks 🙂

Edit:
php show.php

<?php 
  echo phpinfo();
  exit;
?>

bash script:

#!/bin/bash
HOME=`dirname $0`;
log(){
    NEW_LOG=$HOME/logs/cloud-`date +%d_%m_%Y`.log
    echo $1 >> $NEW_LOG
}
log "Date: `date`";
data=$(/usr/bin/php -f  $HOME/lib/show.php);
log $data;

output:

Date: Fri Jun 15 19:16:00 PKT 2012
phpinfo()

no luck yet

  • 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-06T14:46:45+00:00Added an answer on June 6, 2026 at 2:46 pm
    myvariable=$(/usr/bin/php -f $HOME/lib/get_fifobuild.php)
    

    Will assign the output from your php script to a variable called “myvariable”.

    Update:

    This will assign the output of the command to the variable, but as you are still having problems I can perhaps suggest a few things:

    1. you have ‘get_builds.php’ and ‘get_fifobuild.php’ elsewhere.

    2. check that $HOME is being set correctly. You may be better with a different variable name here as that environment variable generally is set to your home directory. This however is unlikely to be the problem as you are getting output from the script.

    3. Is the text you gave the exact contents of your PHP file? If you have quotes
      around phpinfo() for example it will cause the output to just be the string “phpinfo()”. In fact, you do not need the echo at all and could make the contents of your PHP file as follows.

    get_fifobuild.php:

    <?php
        phpinfo();
    ?>
    

    Update 2:

    Try changing your script to:

    #!/bin/bash
    HOME=`dirname $0`;
    log(){
        NEW_LOG=$HOME/logs/cloud-`date +%d_%m_%Y`.log
        echo "$1" >> $NEW_LOG
    }
    log "Date: `date`";
    data=$(/usr/bin/php -f $HOME/lib/show.php);
    log "$data";
    

    Basically adding double quotes around the variables in the ‘log’ and ‘echo’ lines. The problem you were having was that only the first line of your php output was being logged.

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

Sidebar

Related Questions

I have a script called a.sh , contents of which are: //a.sh: #!/bin/bash temp=0
i need help in bash script I have a lic.txt at domain.com which contains
I need your help with a short bash script. I have a folder, which
Currently I have a bash script which runs the find command, like so: find
I have a Makefile from which I want to call another external bash script
I have a bash script that installs some software. I want to fail as
i have this problem: I have created a bash script that performs some tasks.
I wrote a bash script which can modify php.ini according to my needs. Now
I have cron job - php script which is called one time in 5
I have a php script which is responsible for sending emails based on a

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.