- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Help with script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2012 05:59 PM
04-01-2012 05:59 PM
Help with script
I have this script but instead of setting this for one interface, I would like for it to prompt me for the following interfaces..
eth0, etc1,eth2,eth3, etc.
How can I do this with the script provided? Thanks a lot, or if anyone out there that has a script in place and would like to share.
hostname=""
ip=""
netmask=""
gw=""
answer="n"
device="eth0"
hwaddr=`ifconfig $device | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
dns1="64.94.1.1"
dns2="64.94.1.3"
curTTY=`tty`
exec < $curTTY > $curTTY 2> $curTTY
clear
while [ "x$answer" != "xy" ] && [ "x$answer" != "xY" ] ; do
echo -n "enter hostname: "; read hostname
echo -n "enter ip: "; read ip
echo -n "enter netmask: "; read netmask
echo -n "enter default gw: "; read gw
echo -n "hard set '100baseTX full-dulplex' [y/n] " ; read opts
echo
echo You entered:
echo -e "\thostname: $hostname"
echo -e "\tip: $ip"
echo -e "\tnetmask: $netmask"
echo -e "\tdefault gw: $gw"
echo -e "\tset 100baseTX full-duplex: $opts"
echo -n "Is this correct? [y/n] "; read answer
done
sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network
echo GATEWAY=$gw >> /etc/sysconfig/network
echo DEVICE=$device > $scrFile
echo BOOTPROTO=static >> $scrFile
echo ONBOOT=yes >> $scrFile
echo NM_CONTROLLED=no >> $scrFile
echo HWADDR=$hwaddr >> $scrFile
echo IPADDR=$ip >> $scrFile
echo NETMASK=$netmask >> $scrFile
echo USERCTL=no >> $scrFile
echo DNS1=$dns1 >> $scrFile
echo DNS2=$dns2 >> $scrFile
%end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2012 08:20 PM
04-01-2012 08:20 PM
Re: Help with script
>I would like for it to prompt me for the following interfaces.. eth0, etc1,eth2,eth3, etc.
You could get all of them from the command line. Or you could read all of them after a prompt. Or prompt one at a time.
From the command line:
...
while [ $# -gt 0 ]; do
device=$1
hwaddr=`ifconfig $device | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
...
shift
done