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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:34:43+00:00 2026-05-21T15:34:43+00:00

I want to create a simple ‘history’ feature for my linux-web based terminal. The

  • 0

I want to create a simple ‘history’ feature for my linux-web based terminal.

The user can type in any linux command in the textbox. After pressing return, that command is actually executed on linux shell and using exec() function, I return the output on the browser.

When the user types in a keyword, such as ‘history’ in the textbox, then the last ten linux commands typed into the texbox will be shown. How can i implement that?

  • 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-21T15:34:43+00:00Added an answer on May 21, 2026 at 3:34 pm
    $('#submit').click(
    
        function (){
    
            $.ajax({
              url: "test.php",
              method: "get",
              dataType: "text", 
              data: {cmd: $('#command').val() },
              success: function(data){ 
                $('#display').html(data);
              }
            });
    
        }
    
    )
    
    
    <div id="display"></div>    
    <input type="text" id="command"/>
    <a href="#" id="submit">submit</a>
    

    On test.php, get the command, execute it, and display the result.

    $cmd = $_GET['q'];
    
    exec($cmd, $output);
    
    echo "<pre>";
    print_r($output);
    echo "</pre>";
    

    UPDATE:: there you go, your complete code

    <script src="jquery.js"></script>
    <script>
    
    var commands = new Array();
    
    $(function (){
        $('#cmd').keydown(
        function (event){
            if(event.keyCode == 13){
                event.preventDefault(); 
                /*you can call your function here*/
                var tmp = $(this).val();
                commands.push(tmp);
                if(tmp == 'history')
                {
                    showlog();
                    return false;               
                }           
                $.ajax({
                  url: "exec.php",
                  method: "get",
                  dataType: "text", 
                  data: { q: tmp},
                  success: function(response){ 
                     $('#txtOut').html(response);
                  }
                });
                /*still you can it here*/
              }
            }
        );  
    });
    
    function showlog()
    {           
        $('#txtOut').html(function ()
        {
            var txt="<br/>";
            for(var i=1; i<=commands.length-1; i++)
            {
                txt += commands[i]+"<br/>";
            }
            return txt;
        });
    }
    
    </script>      
    <input type="text" id="cmd"/>
    <a href="#" id="showlog">show log</>
    <div id="txtOut"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a very simple HTML/AJAX based GUI for a Python program.
I want to create simple equalizer for android. How can I do it? Try
I want to create simple dummy tag which can work with Struts2. I have
I want to create a simple method that accepts both value type and reference
I want to create a simple table and make it available for user to
I want to create a simple http proxy server that does some very basic
I want to create a simple box with a header bar containing a title
I want to create a simple bit of JS code that creates an image
Let's say that you want to create a dead simple BlogEditor and, one of
I'm making a simple form to create polls, therefore I want the possibility to

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.