Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old October 23rd, 2003, 09:29 AM
btrail btrail is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Rochester, NY
Posts: 3 btrail User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Local variable not resetting--Win shell

I'm writing a simple script to scan systems on my NT/W2K/XP network for the existence of a particular file and report relative to the file's date.

I want various checks to happen on each loop including one check on the "system" variable %ERRORLEVEL%. What I am finding is that this variable doesn't get reset on each pass

code sample:
FOR /F %%a IN (%1) DO (
IF NOT EXIST "\\%%a\admin$\system32\." ECHO %%a not online
dir "\\%%a\c$\program files\jsconsole\ntcon.bat" | FINDSTR "10/10" > nul
IF ERRORLEVEL 0 (
echo %%a has right file
) ELSE (
echo %%a has wrong file or no file at all
)
)

In this case ERRORLEVEL comes into the FOR loop as one value and won't change inside the loop. Is there a way to refresh the value inside the loop, a sort of local variable? Also, how can I break out of a FOR loop... as in BREAK or CONTINUE in Perl?

Any comments...

BTrail

Reply With Quote
  #2  
Old November 13th, 2003, 12:15 PM
btrail btrail is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Rochester, NY
Posts: 3 btrail User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post Re:Local variable not resetting--Win shell

In my original posting, the line I use could be more clear:

dir "\\%%a\c$\program files\jsconsole\ntcon.bat" | FINDSTR "10/10" > nul

could better read:

dir "\\%%a\c$\file_and_path_to_search" | FINDSTR "search_string"

Hope this helps... the subsequent call to ERRORLEVEL is where I have the trouble and the variable doesn't reflect whether the system "dir" command was successful or not.

B Trail

Reply With Quote
  #3  
Old August 26th, 2004, 06:14 PM
btrail.skinna.n btrail.skinna.n is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 btrail.skinna.n User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
best downloads on the web

yo im the real btrail and the best btrail check out our site www.btrail.skinna.net wicked downloads chat sites forums battle boards registration is free and all the down loads are free btrail and skinna hve been working hard on there new album due for release early 2005 check out the sedukshun crew at www.btrail.skinna.nethttp://www.btrail.skinna.net

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Local variable not resetting--Win shell


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 On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway