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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:53:12+00:00 2026-05-14T23:53:12+00:00

I have an execute(String cmd) in a jsp script that calls the exec method

  • 0

I have an execute(String cmd) in a jsp script that calls the exec method from the Runtime class.

It works when I call a local command, like a php script stored on the server. for example: /usr/bin/php /path/to/php/script arg1 arg2

So I guess my execute command is ok, since it is working with that.

Now when I try to call lynx, the text-based web browser, it does not work.

If I call it in a terminal, it works fine:
/usr/bin/lynx -dump -accept_all_cookies ‘http://www.someurl.net/?arg1=1&arg2=2‘

But when I call this from my execute command, nothing happens…

Any idea why?

This is my execute method:

public String execute(String cmd){


        Runtime r = Runtime.getRuntime();
        Process p = null;
        String res = "";

        try {
                    p = r.exec(cmd);
                    InputStreamReader isr = new InputStreamReader(p.getInputStream());
                    BufferedReader br = new BufferedReader(isr);
                    String line = null;
                    //out.println(res);
                    while ((line = br.readLine()) != null) {

                    res += line;

                    }
                    p.waitFor();
                    } catch (Exception e) {
                    res += e;
                    }
                    System.out.println(p.exitValue());

        return res;

    }
  • 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-14T23:53:12+00:00Added an answer on May 14, 2026 at 11:53 pm

    I solved it…. by calling lynx into a php script, php script that I called from the Jsp script…

    It’s a shitty solution but at least it works… I still do not really understand why the exec command from Java works that way…

    Thanks for your help anyway Andrzej (Czech I guess from the name..? ^_^), somehow you put me on the way!

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

Sidebar

Related Questions

I am using java Runtime.exec() method to execute bat file,in bat file i have
I have the Execute SQL Script package that contains the script to insert about
I wanted to run a .cmd file from Java. I have something which works
I have code: sudo_cmd=echo -e \\$cmd\\ >> $CACHE_CONF echo $sudo_cmd that prints string: echo
Does anyone know how to execute a PowerShell script from SSIS? I have created
I have a Java program that executes from Spring Qquartz every 20 seconds. Sometimes
I have a shell script in which I have to execute two queries (on
I have a program that accepts a Cmd command as a command argument. Basically
I have a class named Entry declared like this: class Entry{ string Id {get;set;}
I have a weird problem with my sql script. I have a string $query

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.