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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:38:00+00:00 2026-06-14T07:38:00+00:00

I am trying to display the output of a bash script to a div

  • 0

I am trying to display the output of a bash script to a div on my webpage. But when i load the page nothing appears. Here is what I have so far.

Jquery ajax function. Discon is the name of the div the info is supposed to be appearing in.

$(document).ready(function() {
    $.ajax({
            type: "POST",
            url:  "discon.php",
            data: "Discontinuities",
            success: function(data) {
            $('#discon').html(data)
            }
    });
 });

Here is my php to take what is in the jquery. Note the commented out parts are places where i was trying different options in php. I have tried several and nothing seems to work.

<?php

 echo passthru('/opt/bin/enc_current_test');

//$discon = exec('/opt/bin/enc_current_test', $o, $r);
//if ($r != 0){
//      print 'Error running command';
//      exit($r);
//}
//else{
//      print implode("\n", $o);
//}

?>

I have another bash script that is displaying to the same page in a different Div and it works fine so my question is why is this one giving me a problem. Here is the bash script.

#!/bin/bash

while [ true ]
do
    counter=0

    clear
    date

    dir=/test/`date "+%Y/%m/%d"`

    cd $dir
    echo Writing On: `pwd`

            for i in `ls`
            do
                    if [ -n "$(ls -l $i/* | grep `date "+ %k:%M"`)" ];
                    then
                            echo $i
                            let "counter+=1"
                    fi
            done
    echo
    echo "Total Current Streams: "
    echo $counter
    sleep 60
    clear
done

I am thinking it is because the script sleeps for 60 seconds, but i added the tag in my html to refresh the page at that same interval and it still does not work. Any idea as to why this script would not display? Kind of at a loss at this point. Thanks for any replies.

  • 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-14T07:38:01+00:00Added an answer on June 14, 2026 at 7:38 am

    your bash script runs infinite loop

    while [ true ]
    do
    ...
    done
    

    the web server keeps waiting the answer from script and doesn’t send it to client (browser)

    try to comment while loop and sleep command in bash script

    also i guess you don’t want to see extra characters written by clear command, so comment them too

    #!/bin/bash
    
    #while [ true ]
    #do
        counter=0
    
    #    clear
        date
    
        dir=/test/`date "+%Y/%m/%d"`
    
        cd $dir
        echo Writing On: `pwd`
    
                for i in `ls`
                do
                        if [ -n "$(ls -l $i/* | grep `date "+ %k:%M"`)" ];
                        then
                                echo $i
                                let "counter+=1"
                        fi
                done
        echo
        echo "Total Current Streams: "
        echo $counter
    #    sleep 60
    #    clear
    #done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display certain details using a bash script but the output
I am trying to display this output, as a date: 1296524384 But when I
I am trying to display console.log(r.get('info')) but, i am getting the output as (an
I'm trying to run a bash script in linux (ubuntu but also fedora) but
I am trying to display my output in Jtext Area. while ((line1 = br1.readLine())
trying to display data only after variables have been set. $(document).ready(function () { function
Im trying to display some files in a web page so the user can
OS: ubuntu 11.10 Webserver: Apache Code: PHP I am trying to display the output
I have an array of Person pocos, populated below. I'm trying display them alphabetically
I'm trying to display this query output in a Highchart (line). I’dlike to know

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.