Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Batch file help

Original Message
Name: stage1v8
Date: September 7, 2007 at 07:51:26 Pacific
Subject: Batch file help
OS: 2k / XP
CPU/Ram: P4 / 512MB
Model/Manufacturer: dell
Comment:
Hi folks,

I am trying to set up a batch file to run an nbtscan on an IP addresses and then output the results to a text file.

I have the basic scan which works a treat:

scan.bat 192.168.1.1

@echo off
date /t >> %1.txt
time /t >> %1.txt
echo IP Address being scanned %1 >> %1.txt
nbtstat -A %1 >> %1.txt
echo --------------- >> %1.txt


Now I want to get clever :-) and set it up so that I can list multiple IP addresses in a text file and get it to work its way through it.

I started by using this which allows me to read 1 IP address from a file:

FOR /F %%A in (ip.txt) do set ip=%%A
date /t >> %ip%.txt
time /t >> %ip%.txt
echo IP Address being scanned %ip% >> %ip%.txt
nbtstat -A %ip% >> %ip%.txt
echo --------------- >> %ip%.txt

Now I know if I use something like:

FOR /F "tokens=1,2,3,4,5 delims=," %%A in (ip.txt) do set ip=%%A

I can start to list several IP addresses with a comma delimiter but I want to set up some kind of loop where it runs the scan for each ip address until it comes to the end of the list and stops.

I have this running every 30 minutes and want a seperate file for each IP.

Any thoughts/suggestions?

Cheers

Jon


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: September 8, 2007 at 00:19:25 Pacific
Subject: Batch file help
Reply: (edit)
IP.txt needs one IP on each line. Then:

FOR /F %%A in (ip.txt) do (
bla
bla
)



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: User123456789
Date: September 9, 2007 at 06:24:17 Pacific
Subject: Batch file help
Reply: (edit)
I'm a fan of splitting up functions as files, so I would propose something like this :

@echo off
for /F %%A in (ip.txt) do (
call scan.bat %%A
)



Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch file help

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




CPU and Graphics Upgrade Questions

VIRUS ALERT in Taskbar, HELP!

DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC