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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:19:25+00:00 2026-05-27T01:19:25+00:00

I am trying to send data from PHP to a bash script and then

  • 0

I am trying to send data from PHP to a bash script and then output the data back to the user. Why am I unable to send “beans” to the simple.sh and get it echoed back?

In the end, my goal is to get my web browser to output “beans”. Very simple but I can’t get it to work (complete noob).

Here is my test.php:

<?php
echo "<pre>";
    $var = 'beans';
    exec("/var/www/html/dev/simple.sh $var", $output);
    echo var_dump($output);
echo "</pre>";    
?>

Here is my simple.sh:

read var
echo $var

What am I doing wrong?

  • 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-05-27T01:19:25+00:00Added an answer on May 27, 2026 at 1:19 am

    You didn’t execute your shell script so here is the correct code :

    echo "<pre>";
        $var = 'beans';
        exec("sh /var/www/html/dev/simple.sh $var", $output);
        echo var_dump($output);
    echo "</pre>";
    

    Also, your have something wrong with your shell script :

    #!/bin/sh
    echo $1
    

    Note : command READ is for scan the string from the keyboard only!! if you want to pass it by arguments please just echo these $1, $2, $3,… that is your number of argument you entered one by one.

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

Sidebar

Related Questions

I am trying to get some data from the user and send it to
I'm trying to send data from a form to an external script prior to
I am trying to send a variable from a Javascript to a php script
I'm trying to send an archived objective-c object to a php script and then
I have been trying to send xml message from php to asp and output
I am trying to send data from dynamicly generated cheboxes(when ticked) to my php
I am trying to send some data from a LINQ query in C# to
I am currently trying to send some data from and Android application to a
I am trying to send an email message with data collected from an html
i am trying to send email from php i have one php file with

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.