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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:14:17+00:00 2026-06-12T15:14:17+00:00

I would have thought this straight forward, but it doesn’t seem the case. Aim:

  • 0

I would have thought this straight forward, but it doesn’t seem the case.

Aim: I am running a shell script ArgCHeck.sh through my .jsp file. This works fine and I can see the output in my system console.

However when I try and output the line into the browser through HTML, its doesn’t seem to work.

I have tried setting the String to Static final String line = "test"; and this works to output the word test, but not the value I want which is from the other String line.

Its probably something I missed, but any help is appreciate.

<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%!

%>
<%
Runtime r=Runtime.getRuntime();
Process p=null;
String s=null;
String cmd="/tools/scripts/ArgCheck.sh orange";

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


System.out.println(p.exitValue());
%>
<html>
    <head/>
    <body>
        <%
    // This scriptlet generates HTML output
    out.println( String.valueOf( line ));
%>
    </body>
</html>

————————— Edit —————————————————–

That’s what you get when you cut and paste. I read the code and it was obvious. Time for a break.

<%@page import="java.io.*"%>
<%@page import="java.util.*"%>

<html>
<head>
<head/>

<body>


<% 
Runtime r=Runtime.getRuntime();
Process p=null;
String s=null;
String cmd="/tools/scripts/ArgCheck.sh";

p=r.exec(cmd);
InputStreamReader isr=new InputStreamReader(p.getInputStream());
BufferedReader br=new BufferedReader(isr);
String line = null;
while((line = br.readLine()) != null){
out.println(line);
}
p.waitFor();
%>

</body>
</html>
  • 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-12T15:14:18+00:00Added an answer on June 12, 2026 at 3:14 pm

    Here you go.. Just Change the file path .

    <%@page import="java.io.*"%>
    <%@page import="java.util.*"%>
    <%!
    private String runScriptFile(){
        String strRetVal = "";
        Runtime r=Runtime.getRuntime();
        Process p=null;
        String s=null;
        String cmd="D:\\test.bat";
        try{
            p=r.exec(cmd);
            InputStreamReader isr=new InputStreamReader(p.getInputStream());
            BufferedReader br=new BufferedReader(isr);
            String line = null;
            while((line = br.readLine()) != null){
                strRetVal += line + "<br>";
                System.out.println(line);
            }
            p.waitFor();
        }catch(Exception e){
            e.printStackTrace();
        }
        return strRetVal;
    }
    %>
    <%
    String line = runScriptFile();
    %>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Batch File Test</title>
        <head/>
        <body>
    <%
        // This scriptlet generates HTML output
        out.println( String.valueOf( line ));
    %>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thought this would be pretty straight forward, but my value is remaining the same
So i thought this would be straight forward but i keep getting compile errors,
I'm new to AutoFac, but I thought this would be pretty straight forward. I've
I would have thought this one would be simple but I'm trying to change
I would have thought that this would be an easy thing to do, but
I thought this question would have already existed on SO, but then I couldn't
I have, what I thought was a pretty straight-forward query. In normal Sql this
I came across this code on reddit . I would have thought that type
http://www.interact-sw.co.uk/iangblog/2004/04/26/yetmoretimedlocking Why is this line needed? System.GC.SuppressFinalize(tl.leakDetector); I would have thought the finalizer should
Im very new to all coding including jquery. I though this would have been

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.