Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Running bat file


  • Please log in to reply
3 replies to this topic

#1 SysTech Guy

SysTech Guy

  • Members
  • 130 posts
  • OFFLINE
  •  
  • Local time:12:31 PM

Posted 02 July 2011 - 09:33 PM

I am trying to run a batch file (arpping.bat) that will get all of the IP's and mac addresses on the network. Here is the batch file.

REM arpping.bat
ping -n 1 -l 1 %1.%2
arp -a %1.%2

I run the following command from the command line:

C:\> for /l %i in (1,1,254) do arpping 160.82.220 %i

I the receive the following, repeating, output line at the command line:

The process cannot access the file because it is being used by another process.

This keeps repeating until I hit Ctrl C.

Not sure where the problem is.

BC AdBot (Login to Remove)

 


#2 keyboardNinja

keyboardNinja

    Bleepin' Ninja


  • Members
  • 4,815 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:teh interwebz
  • Local time:11:31 AM

Posted 02 July 2011 - 10:31 PM

I'm not sure where the problem is either. I copied the batch file exactly as you have it and used the same command (altered for my local network IP allocations). It worked just fine.

When you run for /l %i in (1,1,254) do arpping 160.82.220 %i, are you in the same directory as arpping.bat?
PICNIC - Problem In Chair, Not In Computer

Posted Image Posted Image

20 Things I Learned About Browsers and the Web

#3 SysTech Guy

SysTech Guy
  • Topic Starter

  • Members
  • 130 posts
  • OFFLINE
  •  
  • Local time:12:31 PM

Posted 05 July 2011 - 04:27 PM

It seemed to work on another machine. Not sure why.

Another issue. I am getting all of the mac and ip's and redirecting to a temp file, then parsing through the list for something readable by using the following command:
findstr dynamic temp.txt


However, when I try to initiate this command it will not execute. Here is the man batch file (there is a timestamp generator at the top, but the bold text is where the work is done:

@echo off
cls
rem Timestamp Generator

rem Parse the date (e.g., Fri 02/08/2008)
set cur_yyyy=%date:~10,4%
set cur_mm=%date:~4,2%
set cur_dd=%date:~7,2%

rem Parse the time (e.g., 11:17:13.49)
set cur_hh=%time:~0,2%
if %cur_hh% lss 10 (set cur_hh=0%time:~1,1%)
set cur_nn=%time:~3,2%
set cur_ss=%time:~6,2%
set cur_ms=%time:~9,2%

rem Set the timestamp format
set timestamp=%cur_yyyy%%cur_mm%%cur_dd%-%cur_hh%%cur_nn%%cur_ss%%cur_ms%

rem Do something with it
[b]loop.bat > temp.txt
findstr dynamic temp.txt > %timestamp%.txt[/b]
rem Clear the environment variables
set cur_yyyy=
set cur_mm=
set cur_dd=
set cur_hh=
set cur_nn=
set cur_ss=
set cur_ms=
set timestamp=

The loop.bat file is just the for loop used above in the previous post

rem loop.bat
for /l %%i in (1,1,20) do arpping.bat 172.26.50 %%i

The temp.txt file is created, but the timestamp is not. I 'rem' the loop.bat call after temp.txt is created and the findstr command workds and creates the timestamped file.

Is this about closing the temp.txt file before launching findstr? I was looking for a command to close a file in batch, could not find one, but not sure if that is the solution.

I have tried running running another batch file from the main inventory batch file that just has the findstr command in it and then redirecting to the timestamp file...that does not work either.

#4 keyboardNinja

keyboardNinja

    Bleepin' Ninja


  • Members
  • 4,815 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:teh interwebz
  • Local time:11:31 AM

Posted 05 July 2011 - 06:38 PM

Well, it seems you know a lot more about batch files than I do. :blink:

Sorry, but I don't know what the solution is.

If you want, I can request help from the staff.

Edited by keyboardNinja, 05 July 2011 - 06:38 PM.

PICNIC - Problem In Chair, Not In Computer

Posted Image Posted Image

20 Things I Learned About Browsers and the Web




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users