#!/bin/bash function AddHost { IP=$(whiptail --inputbox --nocancel "What is the IP of the device to add?" 8 39 192.168.1.10 --title "Add Host" 3>&1 1>&2 2>&3) HOST=$(whiptail --inputbox --nocancel "What is the name of the device to add?" 8 39 Office-PC --title "Add Host" 3>&1 1>&2 2>&3) HOST=$(echo $HOST | tr -dc '[:alnum:]\n\r') echo "$IP $HOST" >> /etc/hosts if whiptail --title "Add Host" --yesno "Do you wish to add more hosts?" 8 78; then AddHost else clear fi } AddHost