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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:39:19+00:00 2026-06-04T03:39:19+00:00

I have the following simple shell script: # get all servers from config sshservers=`node

  • 0

I have the following simple shell script:

#   get all servers from config
sshservers=`node $scriptDir/readconfig.js --command cluster.sshservers`

#for each server
for server in sshservers
do

    #run deployserver with server (server:port format) argument
    if ! sh deployserver --server $server
    then
        exit 1 #failure
    fi

done

Now, the node command to get the sshservers may return an exit code that is nonzero. When this happens, things went horribly wrong and so I would like to quit with an error message.

How would I do this? Would this be the most appropriate way?

sshservers=`node $scriptDir/readconfig.js --command cluster.sshservers`
if ! $?
then
    echo "Error: node readconfig tool failed."
    exit 1
fi

Also, how do I output the stderr of this node command when things go so horribly wrong?

Finally, is the way I exit when sh deployserver fails proper, or should this be done differently?

  • 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-04T03:39:21+00:00Added an answer on June 4, 2026 at 3:39 am

    To see if the last command was sucessfull you can do this :

    if [ "$?" != "0" ]
        then
            //do something
        fi
    

    The stderr should find it’s way to the console you are running the script by itself.

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

Sidebar

Related Questions

I am writting shell script. I have following files: 2012-03-08_16-37-41 2012-03-08_16-37-43 2012-03-08_16-37-46 2012-03-08_16-37-55 Simple
I have following rather simple query select count(*) from tbl t1, tbl t2 For
I have the following simple python test script that uses Suds to call a
I have the following simple script for backing up my website files and db.
I have the following shell script and want to change the filename db_backup.sql to
I am trying a simple shell script like the following: #!/bin/bash up_cap=$( cat result.txt
Let's say I have the following simple script: print ID : ; $ID =
I have a script that runs from a newly created shell. OS is Red
I have a simple shell script that builds my Roxygen documents, builds the package,
I have a bash shell script that loops through all child directories (but not

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.