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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:22:18+00:00 2026-06-09T03:22:18+00:00

I have done a shell script that gets the output of a .jar file

  • 0

I have done a shell script that gets the output of a .jar file and assign in to a variable.

rewards_generator.sh

APP_ROOT=/home/testApps/
JAR=${APP_ROOT}ClusterGenerator/generator.jar

#get clusters
clusters=$(loadClusters $1)

for i in `echo $clusters | sed 's/,/ /g'`
do
    #pull cluster records from database and save query return status to $x
    x=$(/usr/IBM/WebSphere/ProcServer/java/bin/java ${JAR} ${i/-/_} 2>&1)
done

Basically, what I’ve done to the java app is to System.out.print the query return status. Then used the 2>&1 in bash in order to get into the output stream and assign the value to a shell script variable.

Now how can I get the return value of a perl script and assign it to a shell script variable? Is it the same as the one I’ve done above or is there any other approach to do this?

  • 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-09T03:22:20+00:00Added an answer on June 9, 2026 at 3:22 am

    You can use backticks to record the output of an external command in a bash script.

    Here’s a simple example:

    #!/bin/bash
    
    # Execute the script, recording output to a variable
    x=`/path/to/script.pl`
    
    # Display or act on the output some time later
    echo "script output: $x"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a shell script that saves the output of a command that is
#!/bin/bash for((i=1;i <=10;i++)) do php /var/www/get.php done I have the above shell script that
I have found a useful shell script that shows all files in a directory
I have a shell script that unzips a bunch of files, then processes the
I have a shell script that I can run successfully from the command line.
I have a Unix shell script (bash) that sources some environment variables and then
I have a shell script which has a for loop that prints the value
I have a problem updating a value of a variable in a shell script
I have a bash shell script that loops through all child directories (but not
I have a shell script that contains the following loop. i=0 upperlimit=$verylargevariable do complexstuff

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.