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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:53:40+00:00 2026-06-07T22:53:40+00:00

i need to redirect stout and stderr in bash each to separate file. well

  • 0

i need to redirect stout and stderr in bash each to separate file.
well i completed this command:

  ((/usr/bin/java -jar /opt/SEOC2/seoc2.jar 2>&1 1>&3 | tee --append /opt/SEOC2/log/err.log) 3>&1 1>&2 | tee --append /opt/SEOC2/log/app.log) >> /opt/SEOC2/log/combined.log 2>&1  &

which works fine running from a command line.

trying to put the very same command into bash script

 ...
 12 cmd="(($run -jar $cmd 2>&1 1>&3 | tee --append $err) 3>&1 1>&2 | tee --append $log) >> $combined 2>&1"
 ...
 30                 echo -e "Starting servis..." 
 31                 $cmd &
 32                 pid=`ps -eo pid,args | grep seoc2.jar | grep -v grep | cut -c1-6`
 33                 if [ ! -z $pid ]; then
 ...

leads to error like this:

   root@operator:/opt/SEOC2# seoc2 start
   Starting servis...
   /usr/local/bin/seoc2: line 31: ((/usr/bin/java: dir or file doesn't exist

tried to cover this command by $( ), ` ` etc but with no effect at all 🙁

any suggestion or advice would be very appreciated, playing around for hours already :/

thanx a lot
Rene

  • 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-07T22:53:41+00:00Added an answer on June 7, 2026 at 10:53 pm

    If you store the whole command line in a variable you have to use eval to execute it:

    cmd="(($run -jar $cmd 2>&1 1>&3 | tee --append $err) 3>&1 1>&2 | tee --append $log) >> $combined 2>&1"
    ...
    eval $cmd &
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What we need: redirect to each user's specific page after their login. What we
I need to redirect web requests of the form /{language}-{country}/{file} to: /{language}-{country}/{file} if it
I need to redirect any results in command prompt to richtext box. Can any
I need to redirect a page like this: http://example.com/clients/themes?domain=localhost.com this link should be redirected
I need to redirect the URLs like this http://mysite.com/store/store-name to http://mysite.com/stores/products/store-id . Note that
I need to redirect the following two URLs as shown: http://domain.com/folder/file.php -> http://domain.com/folder2/ http://damain.com/folder/file2.php?id=13
How to execute JavaScript file by ant and redirect stdout and stderr to files?
I need to redirect /search?keywords=somesearchterm to /search/somesearchterm This seems incredibly basic but I've been
I need to redirect all urls with matching keyword, regardless of position in link,
I need to redirect user to another page called free.php from index page, if

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.