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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:29:28+00:00 2026-05-13T13:29:28+00:00

I have a script which, given an ID, kicks off some complex processes and

  • 0

I have a script which, given an ID, kicks off some complex processes and puts an RTF file onto stdout. For example, you might call it with something like foo.exe 27 to point it at ID 27.

Now I’d like to write a short PHP page which:

  • accepts a GET id parameter
  • checks that the parameter is an integer number
  • calls shell_exec(...) on the script (we’ll assume it’s on the $PATH)
  • responds with the output of the script, popping up the usual browser-specific download prompt, just as if they’d clicked on the file in a link

Can this be done easily?

  • 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-13T13:29:28+00:00Added an answer on May 13, 2026 at 1:29 pm

    This should be pretty simple. Just what you need is to make sure you’re not inserting weird data to the script, to avoid any breaks, and to redirect STDERR to STDOUT to avoid to have errors and not to be able to see them.

    <?php
    
    // configuration
    $scriptName = 'foo.exe';
    
    // sets the header to send raw data to the browser
    header('Content-Type: text/plain');    
    
    // disables the timeout for your script
    set_time_limit(0);
    
    // if the input is not an integer
    if (! is_integer($_GET['id']))
    {
            // throw to forbidden page
            header("HTTP/1.0 403 Forbidden");
            die();
    }
    
    // parameter to use as parameter of 
    // the command to call
    $parameterId = (int) $_GET['id'];
    
    // preparing the command and redirecting STDERR to STDOUT (the browser)
    $command = "$scriptName $parameterId 2>&1";
    
    // executing command and outputing it
    print(shell_exec($command));
    

    Hope it helps!

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

Sidebar

Ask A Question

Stats

  • Questions 278k
  • Answers 278k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer iterator is a dependent type (it depends on a template… May 13, 2026 at 3:13 pm
  • Editorial Team
    Editorial Team added an answer Yes, Java has it and it's called XML Encoding. Check… May 13, 2026 at 3:13 pm
  • Editorial Team
    Editorial Team added an answer You probably have Configure::write('Security.level') set to 'high'. In that setting,… May 13, 2026 at 3:13 pm

Related Questions

I have a data warehouse containing typical star schemas, and a whole bunch of
I posted a question earlier today when I'd not zeroed in quite so far
I've got a website that has a form that the user can type in.
I am currently developing on an advertising system, which have been running just fine
Edit: I have since found and published an efficient and elegant solution that transforms

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.