Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Reading a file using a batch file

Original Message
Name: slomifier
Date: March 23, 2008 at 20:13:39 Pacific
Subject: Reading a file using a batch file
OS: XP
CPU/Ram: 512
Comment:
I'm trying to create a batch script that can read a single lined file containing a password (making a login script), than set the read string as a variable. So far, all my attempts have failed. I'm pretty new to batch files, so the simplest script possible would be the best. This is what I've tried so far:

@set tpass=(TYPE "c:\login\%name%s_pass.bat")

This is what I've tried so far, but instead of reading the file and setting it as tpass, it sets tpass as "(TYPE "c:\login\%name%s_pass.bat")".

%name% is the name their trying to login as

tpass is the pass they entered to compare with the stored pass

%name%s_pass.bat is the file I'm trying to read (but It doesn't have to be a bat)


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: March 24, 2008 at 01:47:10 Pacific
Subject: Reading a file using a batch file
Reply: (edit)

set /p tpass=< c:\login\%name%s_pass.bat


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 2
Name: slomifier
Date: March 24, 2008 at 08:06:23 Pacific
Subject: Reading a file using a batch file
Reply: (edit)
Having more problems now. I'll copy the main part of my script down:

@:LOGIN
@set /p name=UserName?
@echo Checking...
@ping -n 3 127.0.0.1 >NUL
@if exist c:\login\%name%s_name.bat goto NAMEPASS
@GOTO NAMEFAIL

@:NAMEPASS
@set /p pass=PassWord?
@set /p tpass=< c:\login\%name%s_pass.bat
@if %tpass%==%pass% GOTO LOGINTRUE
@if not %tpass%==%pass% GOTO LOGINFALSE
@pause

(This isn't the entire script, just the part I'm having problems with)

I hope this helps explain what I'm trying to do.

Again, %tpass% is the stored password that is used to compare to the password that they enter at login (%pass%).


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: March 25, 2008 at 01:11:21 Pacific
Subject: Reading a file using a batch file
Reply: (edit)
What is the problem?


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 4
Name: ghostdog
Date: March 25, 2008 at 06:04:40 Pacific
Subject: Reading a file using a batch file
Reply: (edit)
this is certainly not the best way to password authenticate a person. If its for fun, then its ok. If not, set up a proper authentication mechanism, not using batch!

Report Offensive Follow Up For Removal

Response Number 5
Name: klint
Date: March 25, 2008 at 07:51:04 Pacific
Subject: Reading a file using a batch file
Reply: (edit)
I agree with ghostdog. Just to illustrate a point, consider the following user's answer to the first prompt:

UserName? nul type C:\input\* & rem


Then the batch file will execute this statement:

if exist c:\login\nul type C:\input\* & rem s_name.bat goto NAMEPASS

And so this user will get to see everyone's name and password.


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Reading a file using a batch file

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




XP Installed to G?

exessive internet traffic

ZoneAlarm Question. Blocked Connect

Windows Live Messenger Problem

Delete $Uninstall after SP3 updates


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC