how to enter password using shell script
how to enter password using shell script
am 03.10.2007 03:38:45 von Jobs Circular group
Hi i want to know if i make script like this script ask your user name
and password .
password should not display on screen .
how to do it with scripting...
nikunj
Re: how to enter password using shell script
am 03.10.2007 04:01:02 von Bill Marcum
On 2007-10-03, Nikunj Khakhar wrote:
> Hi i want to know if i make script like this script ask your user name
> and password .
>
> password should not display on screen .
> how to do it with scripting...
>
stty -echo
Re: how to enter password using shell script
am 03.10.2007 04:07:10 von Icarus Sparry
On Tue, 02 Oct 2007 18:38:45 -0700, Nikunj Khakhar wrote:
> Hi i want to know if i make script like this script ask your user name
> and password .
>
> password should not display on screen . how to do it with scripting...
>
> nikunj
OLDSTTY=$(stty -g)
stty -echo
read password
stty $OLDSTTY
is one approach.
Re: how to enter password using shell script
am 03.10.2007 04:08:50 von Tiago Peczenyj
use read -s (silent mode!)
example:
$ read -sp "password: " PASSWORD
password:
$ echo $PASSWORD
xxx
On 2 out, 22:38, Nikunj Khakhar wrote:
> Hi i want to know if i make script like this script ask your user name
> and password .
>
> password should not display on screen .
> how to do it with scripting...
>
> nikunj
Re: how to enter password using shell script
am 03.10.2007 10:41:36 von Gilles Chehade
On 2007-10-03, Tiago Peczenyj wrote:
> use read -s (silent mode!)
>
> example:
> $ read -sp "password: " PASSWORD
> password:
>
> $ echo $PASSWORD
> xxx
>
What works on your shell isn't necessarily working elsewhere ;-)
$ read -sp "password: " PASSWORD
sh: read: -p: no coprocess
$
--
Booze is the answer. I don't remember the question.
Re: how to enter password using shell script
am 03.10.2007 11:09:09 von Cyrus Kriticos
Gilles Chehade wrote:
> On 2007-10-03, Tiago Peczenyj wrote:
>> use read -s (silent mode!)
>>
>> example:
>> $ read -sp "password: " PASSWORD
>> password:
>>
>> $ echo $PASSWORD
>> xxx
>>
>
> What works on your shell isn't necessarily working elsewhere ;-)
>
> $ read -sp "password: " PASSWORD
> sh: read: -p: no coprocess
> $
>
$ echo -n "password: "; read -s
--
Best regards | "The only way to really learn scripting is to write
Cyrus | scripts." -- Advanced Bash-Scripting Guide
Re: how to enter password using shell script
am 03.10.2007 11:10:17 von Cyrus Kriticos
Gilles Chehade wrote:
> On 2007-10-03, Tiago Peczenyj wrote:
>> use read -s (silent mode!)
>>
>> example:
>> $ read -sp "password: " PASSWORD
>> password:
>>
>> $ echo $PASSWORD
>> xxx
>>
>
> What works on your shell isn't necessarily working elsewhere ;-)
>
> $ read -sp "password: " PASSWORD
> sh: read: -p: no coprocess
> $
>
$ echo -n "password: "; read -s PASSWORD
--
Best regards | "The only way to really learn scripting is to write
Cyrus | scripts." -- Advanced Bash-Scripting Guide
Re: how to enter password using shell script
am 03.10.2007 11:50:11 von Stephane CHAZELAS
2007-10-03, 11:09(+02), Cyrus Kriticos:
[...]
>> $ read -sp "password: " PASSWORD
>> sh: read: -p: no coprocess
>> $
>>
>
> $ echo -n "password: "; read -s
read -s is zsh or bash specific. Nothing standard here. In
ksh93, there's a read -s but that means something completely
different. The only standard read option is "-r".
To do it more portably, you need stty -echo as another poster
mentionned. And remember that "read" without "-r" has a very
special meaning to the shell.
--
Stéphane
Re: how to enter password using shell script
am 03.10.2007 12:18:28 von Gilles Chehade
On 2007-10-03, Cyrus Kriticos wrote:
> Gilles Chehade wrote:
>> On 2007-10-03, Tiago Peczenyj wrote:
>>> use read -s (silent mode!)
>>>
>>> example:
>>> $ read -sp "password: " PASSWORD
>>> password:
>>>
>>> $ echo $PASSWORD
>>> xxx
>>>
>>
>> What works on your shell isn't necessarily working elsewhere ;-)
>>
>> $ read -sp "password: " PASSWORD
>> sh: read: -p: no coprocess
>> $
>>
>
> $ echo -n "password: "; read -s PASSWORD
>
$ echo 'password: '; read -s PASSWORD
password:
test
$
`stty -echo` is a far better solution in my opinion and not specific
to one shell
Gilles
--
Booze is the answer. I don't remember the question.
Re: how to enter password using shell script
am 03.10.2007 19:00:00 von unknown
Post removed (X-No-Archive: yes)
Re: how to enter password using shell script
am 03.10.2007 20:08:12 von Stephane CHAZELAS
2007-10-03, 10:00(-07), Michael Vilain:
[...]
>> > $ echo -n "password: "; read -s
>>
>> read -s is zsh or bash specific. Nothing standard here. In
>> ksh93, there's a read -s but that means something completely
>> different. The only standard read option is "-r".
>>
>> To do it more portably, you need stty -echo as another poster
>> mentionned. And remember that "read" without "-r" has a very
>> special meaning to the shell.
>
> Also, on some vendor's systems, passwd is specifically coded to only
> work from a terminal device as a security precaution. The way around
> this is to use expect:
[...]
I don't think it's related to the OP's question though.
But if you want to behave like the passwd command in that
regard, you can simply do
{
old_settings=$(stty -g)
stty -echo
printf 'password: '
IFS= read -r passwd
stty "$old_settings"
} <> /dev/tty >&0
(remember to always put stty -echo *before* issuing the prompt).
--
Stéphane
Re: how to enter password using shell script
am 04.10.2007 13:31:45 von Jobs Circular group
On Oct 3, 1:08 pm, Stephane CHAZELAS wrote:
> 2007-10-03, 10:00(-07), Michael Vilain:
> [...]>> > $ echo -n "password: "; read -s
>
> >> read -s is zsh or bash specific. Nothing standard here. In
> >> ksh93, there's a read -s but that means something completely
> >> different. The only standard read option is "-r".
>
> >> To do it more portably, you need stty -echo as another poster
> >> mentionned. And remember that "read" without "-r" has a very
> >> special meaning to the shell.
>
> > Also, on some vendor's systems, passwd is specifically coded to only
> > work from a terminal device as a security precaution. The way around
> > this is to use expect:
>
> [...]
>
> I don't think it's related to the OP's question though.
>
> But if you want to behave like the passwd command in that
> regard, you can simply do
>
> {
> old_settings=3D$(stty -g)
> stty -echo
> printf 'password: '
> IFS=3D read -r passwd
> stty "$old_settings"
>
> } <> /dev/tty >&0
>
> (remember to always put stty -echo *before* issuing the prompt).
>
> --
> St=E9phane
THANKS Every body i have done..
Thanks also to group owner beause this group is very active and i
always get solution with in 30 minute .
Re: how to enter password using shell script
am 04.10.2007 14:29:31 von Janis Papanagnou
On 4 Okt., 13:31, Nikunj Khakhar wrote:
>
> Thanks also to group owner beause this group is very active and i
> always get solution with in 30 minute .
There's no group owner. And it's the _individuals_ that are active.
Janis