hello, I'd like a batch command to prompt me for a password when I try to use it, and only work if I type in the correct password, can this be done?
thanks in advance.
Hi, You can use:
read -s -p "password: " pass;echo
to have the entered password stored in the variable pass.
A few hints:
Anyone who can edit the script can also change it to for example echo $pass, a security risk...
create an encrypted passwordfile, for example with
echo lakris $(echo secretpassword | md5sum ) >> .mypasswd
Make sure the passwd file is only readable by the owner of the script
Test the entered and encrypted $pass against what's in the file for a given user.
It would be a very rudimentary password handling routine but this should get You started!
yikes, your way over my head buddy!?!? perhaps you could give an example. how would I alter the following batch command to make it prompt me for a password to execute it.
@echo off
color 70
if exist "c:\new folder\file.txt" del "c:\new folder\file.txt"
ECHO hi everybody
ECHO.
PAUSE
Sorry, I didnt realise this was a Windows forum, how silly of me!
I wouldn't be able to do it in cmd.exe. Maybe someone else. But I can recommend ss64.com, it has a very good description of a lot of cmd.exe commands and options.
Well, the following is not really a "password" facility in the normal sense - but as far as i know the best you can get in pure DOS without resorting to Cygwin or the like:
1. switch off screen echo so nobody sees what is going on
2. load a commando processor with an input redirection to the keyboard
3. switch back on normal output.
Note that step 3 would only occur after leaving the loaded commando shell, so the "password" is fixed - to "exit[<enter>]". The following should work in real DOS-versions but probably not in WinXP DOS-boxes or the like:
It has been a long time since i last used DOS and i am not sure if it is "con" or "con:", so you have to find that out. IIRC the colon was the sign of a character oriented device, so "con:" should be correct but it might well be the other way round and devices with colons are block-oriented.
Dear All,
I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
I need to run a test SFTP command in a batch mode and what I need to prompt my password after the sftp userid@hostname. I do not have have an ssh key exchanged between my server and the external server. I only have access to it as an sftp server. I must enter my password in my script. How do i... (2 Replies)
hi,
i have a folder with 2000 text file where each file contain a string.
i need to trasform this string like this:
example of file : My name is Mark and I'm a child
the new file must be:
insert into tabella ('My name','My name is Mark and I'm a child');
where the first column is a... (11 Replies)
I need run a command such as ps -ef |grep xxx on a batch of servers, how to write a script to run it without password? don't need go in each server to check?
Thanks (7 Replies)
I am working on a sftp batch script on a Solaris machine and I need to connect using password. This is not an issue when i do it manually but when I want to make this into a script, i find there are no options for password.
Can anyone suggest how I can do it with password? I know using keys is... (3 Replies)
Hi,
I would like to get the output of below command emailed to me in a windows2003 server.
"bpimagelist -hoursago 24 -U"
I will be using "blat" to email the output of this command.But not sure how the above command is called for in a batch file when executed.
Would appreciate if... (1 Reply)
I want to schedule a batch job (SQL)to run every 6 hours in Unix and the AT command syntax does not seem to cover this.
I have created a file ncd_rpt in the directory report and have given the command in this file.
at -f /report/ncd_rpt 1:00 am tomorrow
I schedule this by running
sh... (1 Reply)
How do I execute a batch command from a script, which "waits" with the next command until the first one has finished?
=======
A piece of my script looks like this:
#!/bin/sh
(...)
# run a long batch job:
./run_calculation.sh
# then rename resulting file:
mv output.dat backup.dat
(...)
... (7 Replies)
Hi All
I have a need due time constraint to issue the mail command in background. I have a script that sends a message to a mail address as follows :-
echo "$MLINE" | mail -s "$HOST - $TEXT" name@co.com &
The script runs frequently and I check to see if the script is active and if it is , it... (5 Replies)