MS DOS
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs MS DOS

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old March 20th, 2008, 05:13 PM
closerwalk closerwalk is offline
Registered User
Dev Archives Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 2 closerwalk User rank is Just a Lowly Private (1 - 20 Reputation Level)  
Time spent in forums: 11 m 33 sec
Reputation Power: 0
Batch File: For Loop Help!!!!!!!!!!

Here we go:
I have the following batch file:


Code:
ipconfig | find "IP Address. . . . . . . . . . . . : 10" > ip1.txt

for /f "tokens=1-2 delims=:" %i in (ip1.txt) do echo %%j >ip2.txt
for /f "tokens=1-4 delims=." %i in (ip2.txt) do set IPADDR= %i.%j.%k.%l

echo %username%, %computername%, %date%,%time%,%IPADDR%,LOGGED ON>>\\servername\data\audit\LOGON_LOGOFF_EVENTS.txt


On a windows xp machine this works fine if you past it into a command prompt.

You can test the following code by just pasting into a command prompt or cmd prompt:
You will see that it works as advertised ...

Code:
ipconfig | find "IP Address. . . . . . . . . . . . : 10" > ip1.txt

for /f "tokens=1-2 delims=:" %i in (ip1.txt) do echo %%j >ip2.txt
for /f "tokens=1-4 delims=." %i in (ip2.txt) do set IPADDR= %i.%j.%k.%l

echo %username%, %computername%, %date%,%time%,%IPADDR%,LOGGED ON


Here's the But:

If I run it using the batch file it produces this error:


C:\>ipconfig | find "IP Address. . . . . . . . . . . . : 10" 1>ip1.txt
j was unexpected at this time.
C:\>for /f "tokens=1-2 delims=:" j >ip2.txt)

Any suggestions ???

Reply With Quote
  #2  
Old May 2nd, 2008, 09:37 PM
wwjdcsk wwjdcsk is offline
Registered User
Dev Archives Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 6 wwjdcsk User rank is Just a Lowly Private (1 - 20 Reputation Level)  
Time spent in forums: 1 h 32 m 50 sec
Reputation Power: 0
For loop variables in batch files must use double-percent i.e. %%J

At the command prompt use %J
In a batch file use %%J

Reply With Quote
Reply

Viewing: Web Development Archives FAQs MS DOS > Batch File: For Loop Help!!!!!!!!!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT