Snacks Posted November 20, 2006 Share Posted November 20, 2006 Hey, I'm pretty new to scripting with command prompt, my question is; can i set the value of a variable based on the contents of a .txt format file? E.g.: set IP = the contents of IP.txt Quote Link to comment Share on other sites More sharing options...
rFayjW98ciLoNQLDZmFRKD Posted November 20, 2006 Share Posted November 20, 2006 What you want is called a batch file. The script that you want to write will most likely have a for loop to go through the IP space that you want. I would write one up, but I am feeling lazy, maby later. :-) Quote Link to comment Share on other sites More sharing options...
Snacks Posted November 20, 2006 Author Share Posted November 20, 2006 Sorry it is a batch file I'm making, but I didn't think that was relevant as batch scripts are just command prompt code, right? Any pointers or examples of how to achieve this? Quote Link to comment Share on other sites More sharing options...
moonlit Posted November 20, 2006 Share Posted November 20, 2006 I believe you can feed info by using the opposite method to printing to a file: commandhere.exe <<filehere.txt Probably not the correct syntax but basically the right idea... Quote Link to comment Share on other sites More sharing options...
Snacks Posted November 20, 2006 Author Share Posted November 20, 2006 Thanks for your reply, So I can use something like: set IP << IP.txt ? Quote Link to comment Share on other sites More sharing options...
moonlit Posted November 20, 2006 Share Posted November 20, 2006 Something like that, I'm not sure if it's one < or two << but that's the basic idea, yeah... Quote Link to comment Share on other sites More sharing options...
Snacks Posted November 20, 2006 Author Share Posted November 20, 2006 Will give that a shot, thanks moonlit! Quote Link to comment Share on other sites More sharing options...
moonlit Posted November 20, 2006 Share Posted November 20, 2006 Not a problem, hope it works out :) Quote Link to comment Share on other sites More sharing options...
Snacks Posted November 20, 2006 Author Share Posted November 20, 2006 Couldn't get it working with either syntax, I have googled and only found reference to variables being set from the contents of other .bat files etc. Anyone know if what I'm trying to achieve is possible? Quote Link to comment Share on other sites More sharing options...
cooper Posted November 20, 2006 Share Posted November 20, 2006 Well, for started DOS commands can be no longer than 256 bytes, and I do believe that that is post variable-substitution. So basically, you can't use a variable with more than 253 bytes of content. As you're in control of the file, can't you just put a 'SET VARIABLE=' at the beginning, and then run the file? Alternatively, install the BASH shell on Windows. That's actually a good idea regardless. Quote Link to comment Share on other sites More sharing options...
remkow Posted November 20, 2006 Share Posted November 20, 2006 I had this small script somewhere, and I think it might help you.. it's a kinda lame netbios bruteforcer, but what it does is it reads the user/passes from netbios.txt, and then interprets them as variables, which I think is what you want. FOR /F "token=1,2*" %i in (netbios.txt) DO net use 127.0.0.1IPC$ %i /u: %j Quote Link to comment Share on other sites More sharing options...
Snacks Posted November 20, 2006 Author Share Posted November 20, 2006 As you're in control of the file, can't you just put a 'SET VARIABLE=' at the beginning, and then run the file? Well my problem is that I want to hand out discs for attendees of a LAN party, each disc will have the batch and an IP address, this is to ease the stress of everyone asking "what IP am I?", "how do i set up my TCP/IP" etc. I guess I'm just going to have to make an individual .bat for every attendee. Quote Link to comment Share on other sites More sharing options...
cooper Posted November 20, 2006 Share Posted November 20, 2006 Well my problem is that I want to hand out discs for attendees of a LAN party, each disc will have the batch and an IP address, this is to ease the stress of everyone asking "what IP am I?", "how do i set up my TCP/IP" etc. I guess I'm just going to have to make an individual .bat for every attendee. Set up a domain controller. Make attendees log on to the domain controller, and have it run a boot script on the client that spits out this particular info. One popular method that admins at my work tend to do is to generate a desktop background that faintly contains the IP address and machine name so that after a few too many desktop switches it can be easily deduced what machine you're working on. On a lan-party that might be pushing it, so you could just push a .txt file onto the client desktop that has all the relevant information. You know, their IP, server IPs, ports, etc. Will save you the troubles of distribution too. When they forget their info and removed the file, don't help them but tell them to re-logon to the domain and not remove the .txt file next time. That will teach them really quick that it is to be kept around for the duration of the party. Quote Link to comment Share on other sites More sharing options...
Snacks Posted November 21, 2006 Author Share Posted November 21, 2006 Sounds good, any pointers in regards domain controllers? Samba or Server 2003? I have access to most of the MS Server range thanks to Microsoft's Academic Alliance. Thanks for all the help so far! Quote Link to comment Share on other sites More sharing options...
cooper Posted November 22, 2006 Share Posted November 22, 2006 I'm a UNIX guy, so I have no actual experience with all this stuff aside from the simple fact that I know it can be done since they're doing it were I work, and used it at the bank where I was stationed before. Maybe someone else can fill in the blanks. I'm pretty sure going with any Windows Server OS will prove easiest to set up. As long as the crowd is friendly you shouldn't have much qualms about that one. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.