Shell Script Help

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.

Shell Script Help

Postby mudasir » Mon Dec 24, 2007 5:22 am

AOA,

I am making a script which reads variables from another file. I have accomplished almost all the tasks, only unable to complete one.

What i am doing is that the user will enter IP Address Ranges seperated by space in a variable IP like this

Code: Select all

echo Please Enter IP Ranges Seperated By Space.
read IP
echo -e "IP=$IP" >> /scripts/firewall/firewall.conf

The Input By user can by like 10.10.10 10.10.11 10.10.12
Now the file /scripts/firewall/firewall.conf looks like
IP=10.10.10 10.10.11 10.10.12


Now the file which is retrieving the variables from /scripts/firewall/firewall.conf has code similar to.

Code: Select all

cat /scripts/firewall/firewall.conf | awk '/IP/' | cut -d"=" -f2

This code is working prefectly.

What i want to do is that count the IP Ranges enter by the user.
In the above example like i enter 3 IP Ranges.

Now what my script should do is that count the IP Ranges and create Variables like IP1 IP2 IP3 and so on till the number of IP Ranges reaches, and each IP Range should have the Range Entered by the User like IP1=10.10.10 IP2=10.10.11 IP3=10.10.12

How can i achieve this.

Looking Forward For Your Replies.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
mudasir
Captain
 
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Website: http://www.crystalnetworks.org
Location: Dubai

Postby wacky » Mon Dec 24, 2007 6:28 pm

Code: Select all

n=1
for i in `cat /scripts/firewall/firewall.conf | awk '/IP/' | cut -d"=" -f2`
do
     echo "IP$n=$i"
     let "n=$n+1"
done
wacky
Naik
 
Posts: 94
Joined: Thu Jun 10, 2004 7:42 pm
Location: London, UK

Postby mudasir » Mon Dec 24, 2007 8:11 pm

AOA,

Dear wacky,

I really appreciate it. Thanks alot, you have solved my problem.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
mudasir
Captain
 
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Website: http://www.crystalnetworks.org
Location: Dubai

Postby x2oxen » Tue Dec 25, 2007 10:52 pm

Mudassir why dont you share you new script as well!
Muhammad Usman
+92-321-6640501
Chemonics International
http://usmanpk.com
x2oxen
Major General
 
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Website: http://usmanpk.com
WLM: x2oxen@hotmail.com
Yahoo Messenger: x2oxen
Location: Faisalabad

Postby mudasir » Wed Dec 26, 2007 6:46 am

AOA,

Dear x2oxen,

The script is in testing process right now, as soon the testing is complete, i will share the script with LP Members.

Its basically a FIREWALL script but its a bit more user friendly.

It has a ./install script as well, which will install the firewall.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
mudasir
Captain
 
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Website: http://www.crystalnetworks.org
Location: Dubai

Postby mudasir » Wed Dec 26, 2007 11:15 am

AOA,

Dear LP Members,

I have made a Firewall Script. Download the Firewall Script from

http://www.mediafire.com/?4milupsy0tm

Then follow these Steps.
Before doing any thing Read the ReadMe file.

1. After Downloading untar the file by "tar -xvzf firewall.tar.gz"
2. Then goto the Firewall Directory "cd firewall"
3. Then run the install script "./install"
4. Enter All the Things Asked by the Install Script.



Please Dont run the Install Script again and again, If you miss something, Please Read the ReadMe file.

This script is Still a Beta Version, under testing..
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
mudasir
Captain
 
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Website: http://www.crystalnetworks.org
Location: Dubai

Postby x2oxen » Thu Dec 27, 2007 5:13 am

nice work!
Muhammad Usman

+92-321-6640501

Chemonics International

http://usmanpk.com
x2oxen
Major General
 
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Website: http://usmanpk.com
WLM: x2oxen@hotmail.com
Yahoo Messenger: x2oxen
Location: Faisalabad

Postby mudasir » Thu Dec 27, 2007 7:14 am

AOA,

Thank you Usman.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
mudasir
Captain
 
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Website: http://www.crystalnetworks.org
Location: Dubai


Return to “%s” Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron