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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:07:26+00:00 2026-06-15T06:07:26+00:00

this is a better phrasing of what I intended in System.exit return code isn't

  • 0

this is a better phrasing of what I intended in System.exit return code isn't detected by bash eval. I need a bash script that

  1. runs an application (in my case it’s a java app)
  2. directs stderr to a file
  3. directs stderr + stdout to the terminal
  4. returns the exit code of the app

for some reason, this is hard to do, even though it’s seems to me like a standard config for enterprise applications…
Thanks!

[EDIT]

testing solutions by wrapping this script:

#!/bin/sh
echo "This is Standard Out"
echo "This is Standard Error" >&2
cat meow
  • 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-15T06:07:27+00:00Added an answer on June 15, 2026 at 6:07 am

    This will do your requirements :

    #!/bin/bash
    
    errlog="/var/log/my_app"
    
    exec 2> >(tee "$errlog")
    
    java -jar /path/to/app.jar
    
    exit $?  
    

    EXPLANATIONS

    • exec 2 > catch STDERR (if you provide a file on the right, STDERR will be redirected in this file and no more on the terminal)
    • >( ) is a bash process substitution (this create file descriptors in background)
    • tee is there to both displays STDERR on the terminal & to save STDERR to the logfile
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a newbie in Obj-C. I need to learn this better so please
i am trying to create slider movement graphics. The code explain better this. using
Is there anything more compact (or otherwise better) than this? <x:Array x:Key=titles Type=System:String> <System:String>Mr.</System:String>
I'll try to explain this better on another question. This is the query that
I need your help to understand this better. This is my case. I have
I have a feeling that this is a code smell, and I could be
I've created this code blow that works and does what I want it to
Couldn't think of better phrasing for this question, but basically I want to store
The code can probably explain this better than I can: <div class=wrapper> <div class=inner1></div>
Sorry if this is better suited at serverfault, but I think it learns more

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.