1.

Solve : batch file for ipconfig + ping results?

Answer»

Hi guys!!
I tried searching for this and have had no luck, so I'm hoping someone can help!

I was trying to create a .bat file to email to several clients, and it would output a text file containing their IP SETTINGS and ping results for specific addresses.

I'm able to get the network info from this:

echo off
ipconfig/all > IPResults.txt

I guessing that it should also have something along the lines of:

ping -n 1 xxx.xxx.xxx.250
ping -n 1 xxx.xxx.xxx.249
ping -n 1 xxx.xxx.xxx.248
(then output the results to that same text file)

I'm just having trouble figuring out how to REFERENCE the first 3 octets of the ipconfig result to have the batch ping with specified 4th octets to see what is available.
(Like if the gateway displayed through ipconfig was 192.168.1.1, it would ping 192.168.1.250, .249, and .248, then add the ping results to the text file showing if any of those were available.)

Are you LOOKING to ping the entire subnet?CassieXoxo,

Sounds like what you need is to write this function in C, Basic, C#, etc.  Doing it on the shell is going to be somewhat tough.

If you decide to write it in a language, I think you'll have better results.

Also...

Why do you need an IP to mail someone?

There are also plenty of mass mailers out there, just look around.

Bryan Wilcutt
www.curiousinternet.comThanks for the replies!
Quote from: Squashman on February 15, 2012, 06:35:54 AM

Are you looking to ping the entire subnet?

I was really just looking to ping 2 or 3 IP addresses on the network.

Quote from: bwilcutt on February 16, 2012, 04:15:43 PM

Sounds like what you need is to write this function in C, Basic, C#, etc.  Doing it on the shell is going to be somewhat tough.


I was hoping to stick to the .bat thing because that's the only bit of programming I'm even remotely familiar with, but I'm definitely open to whatever will work best.

Quote from: bwilcutt on February 16, 2012, 04:15:43 PM
Also...

Why do you need an IP to mail someone?

There are also plenty of mass mailers out there, just look around.


Sorry I think I explained this badly! 

A lot of my day in the near future will be spent calling clients to determine if their local area network is setup for DHCP or Static IP addresses. If static, I'll have to gather their network's Gateway, Subnet, and DNS #s and find an available IP address that we can assign to a device that we'll be shipping them.

What I normally have them do over the phone is open cmd, run ipconfig/all then ping xxx.xxx.xxx.250 (since .250 is usually available on most of these NETWORKS) they read me the results and I have everything I need.
Since most of what I do is contained on the cmd prompt, I was thinking it would be much easier to have a .bat script (or something) that I could just email them to open, that would gather all of this info in a text file that they could shoot back to me.

The problem I was running into is the fact that some of the IP addresses of different customers are 192.168.1.x, 10.100.1.x, etc... and I wasn't sure how to get the .bat to ping whatever set of numbers was listed previously by ipconfig

I'm sure there's a more efficient way of doing this, but I guess that's the best way I know.

I really appreciate the help!  You can isolate output lines from ipconfig /all using the FIND command. Example:

ipconfig /all | find "Default Gateway"

Then you can use FOR to parse the line to get an IP address and extract the octets and use the first three plus your selected final one in a ping command. Perhaps if you state which line(es) from the ipconfig /all output contains the IP address(es) you wish to use, a simple script can be written. So more information please.


Quote from: CassieXoXo on February 17, 2012, 02:52:10 PM
A lot of my day in the near future will be spent calling clients to determine if their local area network is setup for DHCP or Static IP addresses. If static, I'll have to gather their network's Gateway, Subnet, and DNS #s and find an available IP address that we can assign to a device that we'll be shipping them.
Do you realize there could be both on the network.  That is how most networks are setup in the first place.   The DHCP server is setup with a range of IP addresses that it can give out to clients that request an IP address.  This is called a POOL.  One of the reasons for the pool is to maintain control of the network so that other devices like, routers, switches and servers can be allocated static IP addresses that the DHCP server is not stepping on.

If you are doing support for your clients networks I would suggest you get a better handle on how their networks are configured by asking them if they know how the network is configured or if they have documentation on how the network was configured.

Better yet it would only take a few seconds to remote into their computer as well.  You could just ask them to remote into their computer and do your voodoo and be done. Quote from: Squashman on February 18, 2012, 06:33:06 AM
Do you realize there could be both on the network.  That is how most networks are setup in the first place.   The DHCP server is setup with a range of IP addresses that it can give out to clients that request an IP address.  This is called a POOL.  One of the reasons for the pool is to maintain control of the network so that other devices like, routers, switches and servers can be allocated static IP addresses that the DHCP server is not stepping on.


Yes, I realize that many networks are setup that way. However, with many of the networks I'm dealing with, DHCP is disabled altogether. In the somewhat rare case that DHCP is enabled, their network uses .1-.250.

Quote from: Salmon Trout on February 18, 2012, 02:47:26 AM
You can isolate output lines from ipconfig /all using the FIND command. Example:

ipconfig /all | find "Default Gateway"

Then you can use FOR to parse the line to get an IP address and extract the octets and use the first three plus your selected final one in a ping command. Perhaps if you state which line(es) from the ipconfig /all output contains the IP address(es) you wish to use, a simple script can be written. So more information please.


I was thinking something like the FOR command would work, but I was having difficulty specifying the variables.
As I wrote,

Quote
Perhaps if you state which line(es) from the ipconfig /all output contains the IP address(es) you wish to use, a simple script can be written. So more information please.


Discussion

No Comment Found