ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
how can I set a command as a variable in windows batch script?
this is the script //its just a test:
SET /P userpass=Enter Password:
::hash = 123
SET userpass1=%cd%md5.exe -d%userpass%
IF "%userhash%" == "%userpass1%" (
) ELSE (
That's why I suggested that you install the ported Linux utilities on your Windows system -- so you can run a Linux shell script on WinDoze.
Granted, the basic DOS command system was a port of the UNIX scripting language, it (the "cmd" shell) has not matured to match even the old Bourne shell.
If you're really "stuck" with cmd, consider spawning the command, piping the output to a file, and then reading the output in your script. 
One trick I often used was to pass the output through a stream editor to create the desired SET commands, and to then call the file from the parent script. Not eligant, but it does work.
Last edited by PTrenholme; 09-06-2007 at 03:07 PM.
Hi, this script i wrote it to set password for USB flash memory, the password will be stored in the batch file as a clear password, so i use md5sum to compare the hash with the user input.
this is version 0.1, where the password is clear text:
::Coded By Dr.Death 2007 V0.1
TITLE = -- L O S T - A N D - F O U N D --
ECHO This Flash Disk belong to <YourName>, If you Found it please call "<Phone #>"
ECHO .::Please Enter Password::.
SET /P UserPass=Enter Password:
IF %UserPass% == password (
ECHO Login Succeeded
) ELSE (
ECHO Access Denied
this is why i need it to be in windows batch script.
for loop will not set the output command as a variable.
This is somewhat off-topic to your original question, but, if you're trying to protect the contents of your flash memory from unauthorized access, wouldn't you be better off just using an encrypted file system on the flash memory?
If, for some obscure reason, you want to stick with Windows, you can easily "simulate" an encrypted file system by making all on the flash memory you wish to protect an encrypted ZIP file, which will require a password for access. (I haven't tried it, but I think that Windows Explorer will request the P/W when you "ckick" on the ZIP file.)
It seems to me that your scheme assumes that whoever finds the flash memory will "boot" the device, not simply mount it and access it's contents. That scenario seems, to me, to be fairly improbable. Who in their right mind would actually boot an unknown device on their system?
P.S. -- I bought a USB flash drive a while ago, and it was delivered with a FAT file system installed. But Fedora was quite happy to reformat as an ext3 file system for me, and installing an encrypted file system on it -- if I wanted to do so -- would probably be quite easy.
Last edited by PTrenholme; 09-09-2007 at 08:20 PM.