We help IT Professionals succeed at work.

Batch file that seperates the ip adresses

This is the other batch file practice out of my textbook to prepare us for the final. This is not a graded assignment or an assignment just help for us to understand better. I am new to all of this and I need to create a batch file which finds your current IP Address, Subnet Mask, Gateway, DHCP Server address, and your lease expiration time and then displays this info on your screen in the following format.
This is my current IP Address:
IPv4 Address. . . . . . . . . . . . : 10.2.2.148(Preferred)
This is my current Subnet Mask:
Subnet Mask . . . . . . . . . . . . : 255.255.0.0
This is my current Gateway:
Default Gateway . . . . . . . . . . : 10.2.1.1
This is my current DHCP Server:
DHCP Server . . . . . . . . . . . . : 10.2.1.254
My DHCP lease expires:
Lease Expires . . . . . . . . . . . : Monday, November 22, 2010 10:48:12 AM
I really have no clue I can get the parts that say THIS IS MY..... but how to get the addresses seperate from the ipconfig is mindboggling. Anyone think they can help me tackle this one. I just got help with a different one and this is the only other one im struggling with. The batch file has to only have these charactors as well exactly like what i posted.
Thanks
PLEASE HELP Again not a homework assignment just preperation help.
Comment
Watch Question

Sr. Architect
Commented:
Here is the example on how to achive this, you can save this code as ip.bat file and then run "ip" as command on command line in the same directory to see the output.

@echo off
ipconfig /all >output.txt

echo This is my current IP Address
type output.txt|find /i "IPv4 Address"

echo This is my current Gateway
type output.txt|find /i "Default Gateway"



Note: This forum is to provide the guidance only, but not to complete any assignment completly, which is for your editational purpose, and so I am just giving you the partial implementation, for other information heads you can implement the same in the similar fashion.


-Rahul Gade
Rahul GadeSr. Architect

Commented:
In the above example, just to avoid executing the command again and again i have taken the output to output.txt, if you want instead you can use "ipconfig /all" everytime when you want to perform | operation.
e.g. ipconfig /all | find /i "IPv4 Address"
will work exactly same as
type output.txt|find /i "IPv4 Address"

-Rahul Gade

Author

Commented:
ok so it brought up what I was looking for but after the IPv4 address came up I got a huge bunch of sentences after how do i make that stop

Author

Commented:
This is my current IP address:
   IPv4 Address. . . . . . . . . . . : 192.168.1.103(Preferred)
'12' is not recognized as an internal or external command,
operable program or batch file.
'Rank:' is not recognized as an internal or external command,
operable program or batch file.
'Was' is not recognized as an internal or external command,
operable program or batch file.
'Yes' is not recognized as an internal or external command,
operable program or batch file.
'johnb6767:' is not recognized as an internal or external command,
operable program or batch file.
'Youre' is not recognized as an internal or external command,
operable program or batch file.
'12' is not recognized as an internal or external command,
operable program or batch file.
'Rank:' is not recognized as an internal or external command,
operable program or batch file.
'Was' is not recognized as an internal or external command,
operable program or batch file.
'Yes' is not recognized as an internal or external command,
operable program or batch file.
'maytrix:' is not recognized as an internal or external command,
operable program or batch file.
'Thanks' is not recognized as an internal or external command,
operable program or batch file.
'Another' is not recognized as an internal or external command,
operable program or batch file.
'Only' is not recognized as an internal or external command,
operable program or batch file.
'12' is not recognized as an internal or external command,
operable program or batch file.
'Was' is not recognized as an internal or external command,
operable program or batch file.
'Yes' is not recognized as an internal or external command,
operable program or batch file.
'Tonygret:' is not recognized as an internal or external command,
operable program or batch file.
'Worked' is not recognized as an internal or external command,
operable program or batch file.
'12' is not recognized as an internal or external command,
operable program or batch file.
'Rank:' is not recognized as an internal or external command,
operable program or batch file.
'Was' is not recognized as an internal or external command,
operable program or batch file.
'Yes' is not recognized as an internal or external command,
operable program or batch file.
'Qlemo:' is not recognized as an internal or external command,
operable program or batch file.
'Did' is not recognized as an internal or external command,
operable program or batch file.
'This' is not recognized as an internal or external command,
operable program or batch file.
'Comment:' is not recognized as an internal or external command,
operable program or batch file.
'BoldItalicUnderlineBulletStepSubtitleIndentLinkQuoteCode' is not recognized as
an internal or external command,
operable program or batch file.
'Tips' is not recognized as an internal or external command,
operable program or batch file.
c:\Batchfiles>


that is what came up
Rahul GadeSr. Architect

Commented:
Can you do the stuffs step by step. This should never happen unless you are firing something as command which is not a command. Also, don't forget to delete the output.txt at the end of every execution, del command can be included in batch file itself.
I tried with everything and see no problem at all.

Can you check with the contents from where are they comming which are shown as

'xxxx' is not recognized as an internal or external command

in the error of the output?



-Rahul

Commented:
Have a look at some of my scripts here:

http://scripts.dragon-it.co.uk/

Will give you some ideas on how to get the ip address from the output of ipconfig for instance.

Steve