1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Bash scripting help

Discussion in 'Programming & Webmastering' started by nick_1992, Nov 13, 2010.

  1. nick_1992

    Joined:
    Jan 3, 2006
    Messages:
    580 (0.19/day)
    Thanks Received:
    19
    Location:
    Manitoba, Canada
    So i'm trying to make a script that validates if the user input is a integer and it works but i don't know how loop the script if the input is invalid, like say they enter a "a" instead of a integer i need to be able to ask for a re-input. This is what i have so far...

    #!/bin/sh
    echo -n "Enter a integer: "
    read x
    if [ $x -eq $x 2> /dev/null ]
    then
    echo -e "$x is an integer"
    else
    echo -e "$x is not an integer"
    fi
  2. nick_1992

    Joined:
    Jan 3, 2006
    Messages:
    580 (0.19/day)
    Thanks Received:
    19
    Location:
    Manitoba, Canada
    Well cancel that, figured it out after hours....
    streetfighter 2 says thanks.
  3. Arel3 New Member

    Joined:
    Nov 7, 2010
    Messages:
    39 (0.03/day)
    Thanks Received:
    3
    If you run in to this problem again? Go in to the process manager of the server and kill the bash process. With the bash process turned off you can then run your tests on whatever you're working on without it getting bashed.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page