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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
~bp
for /f "tokens=*" %%A in (file.txt) do set password=%%A
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
~bp
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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!
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
thx