Link to home
Start Free TrialLog in
Avatar of LuckyLucks
LuckyLucks

asked on

read in a file in batch script

Hi:
  I need to read in a single line (containing a password from a file) in batch script. How can I do this?
ASKER CERTIFIED SOLUTION
Avatar of Wizard_Of_Dos
Wizard_Of_Dos

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LuckyLucks
LuckyLucks

ASKER

i need to read the value out into a variable that can be used in the rest of the batch script. Can you help with this pelase ?

thx
If the value is a single word in a text file, the example i gave does just that.. %i is the variable created. if you care to elaborate further on the specifics more detailed help can be given.
SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ahh Yes thanks Dragon... I didn't specify "set" for use in the batch file.
I do like the approach in your other approach. I wonder if he's trying to use this password to connect to a network share, or perhaps connecting to an ftp server. If the latter he could instead use ftp-s then specify the script containing the server/user/pass and even commands.
In a batch file, just do the following, then reference the Password variable.

~bp
for /f "tokens=*" %%A in (file.txt) do set password=%%A

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
By the way, I can't recall if Gonzo had a 2nd name, but it sounds about right :-)
Bill... I like it... nice ways of hiding the passwords at least a bit from prying eyes!
I think Gonzo's "full"name was something like "Gonzo the Great".  ;-)

~bp
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Interesting.

What versions of windows do or do not support ADS?

Will an ADS follow a file through all typical activities (copy, ftp, zip, robocopy, other utils) or can you expand on what operations drag the ADS along and which don't.

~bp
An equally interesting question Bill ;-)
Some testing would clearly be needed, and SysInternals "streams.exe" would provide a quick check to verify if the ADS remains embedded.  Unfortunately I have to go to work right now, but I'll have a look at this later.  Yes, I know it's 4am ... don't ask!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you LuckyLucks
Just in case anyone stumbles upon this article, and want to implement ADS solution.  It is very easy to view ADS content nowadays.  One product is V Fileviewer.  Exploiter would need to know you are using ADS to hide password information in the first place to comprise ADS method mentioned above.

The exploit methods called out in ADS solution above that do not work to get password information actually do work.  You just need to put "<" directly in front of you batch file name.  Example below.

find /v "" <InititalTest.bat:password