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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:30:00+00:00 2026-06-17T11:30:00+00:00

d is an internal server lookup tool I use. I am looking to allow

  • 0

d is an internal server lookup tool I use.

I am looking to allow a user to input any number between 0 (or 1) and 9999 (let’s call this userinput) and have it display the result of:

d $userinput (e.g. 1234)

Then manipulate the results of that lookup (below gets rid of everything but the IP address to ping later):

 grep -E -o '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'`

I know I need to use the while true; do read $blah etc etc. I am just not familiar with read enough to format it properly and more importantly:

get it to prompt for a numerical input between 0-9999

  • 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-17T11:30:01+00:00Added an answer on June 17, 2026 at 11:30 am

    <–edit–>

    if all you want is the mechanic for prompting, try this:

    echo -n "Enter server number:"
    read userinput
    

    then run validation checks on the input like this:

    if [[ $userinput -lt 0 || $userinput -gt 9999 ]]   # checks that the input is within the desired range
     then
      echo "Input outside acceptable range."
    else
      # insert your grep and ping stuff here
    fi
    

    <–end edit–>

    on first read, i thought your problem sounded ideal for a wrapper script, so i was going to suggest this:

    $ cat wrapper.sh
    #!/usr/bin/bash
    
    userinput=$1
    
    if [[ $# != 1 ]]   # checks that number of inputs is exactly one
     then
      echo "Too many inputs."
      exit 2
    elif [[ $userinput -lt 0 || $userinput -gt 9999 ]]   # checks that the input is within the desired range
     then
      echo "Input outside acceptable range."
      exit 3
    fi
    
    output=`d "$userinput"`
    
    ping_address=`grep -E -o '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' <("$output")`
    
    ping "$ping_address"
    

    then call the script with like this:

    $ wrapper.sh 1243
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get an internal server error with the following code... any suggestions: <form name="user"
I am getting 500 Internal Server Error when I used ajax call. What is
In FireBug I see NetworkError: 500 Internal Server Error - http://hostname:5987/controllerName/PageName?input=asdf%20%3Cd%20 code $.ajax({ url:
The app runs fine using django internal server however when I use apache +
I'm developing an internal server-monitoring/management tool in Django, which I'm not very familiar with.
I am getting NetworkError: 500 Internal Server Error - http://localhost:5963/default.aspx/Call when am calling this
My ASP.NET always starts like this with the internal server: http://localhost:50793/Website/ I use FckEditor
I get an 500 internal server error and in the log files it writes:
I am getting an internal server error when I am attempting to upload images
I get 500 internal server error in Windows Azure (on localhost too) if I

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.