Link to home
Start Free TrialLog in
Avatar of deibel
deibelFlag for Germany

asked on

Bash Syntax Check

Hi experts,

I'm working with a bash script which is for the ip-configuration.
So the user can type in his ip and subnetmask and broadcast and networkadress and his Defaultgateway like:

echo "Type in your ip:"
read IP
echo "Type in your Subnetmask:"
read Subnetmask
echo "Type in your Broadcast:"
read Broadcast
echo "Type in your Networkadress:"
read Network
echo "Type in your Defaultgateway:"
read Gateway


So yet i Need a kind of Syntax check or something else so that the defaultgateway is only validate when the Input is
between the Network and the broadcast like this:

Network < Gateway < Broadcast
Avatar of ozo
ozo
Flag of United States of America image

[ $Network -lt $Gateway ] && [ $Gateway -lt $Broadcast ] && echo valid
Avatar of deibel

ASKER

Ozo Thank you for your help.

I got a Little question how can i use it in a whileloop or in a if else so that the Programm only accept the right Input? So when the Input is worng that the Programm goes to :echo "Type in your Defaultgateway:"
 read Gateway
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deibel

ASKER

Ty for your help.