在shell里su - user
那个passwd怎么输入啊?
万分感谢
6 个解决方案
#1
直接输入就行了,输入密码时,你本身是看不见的
test@linux-58hm:~> su - root
Password:
在后面输入密码就行了!
test@linux-58hm:~> su - root
Password:
在后面输入密码就行了!
#2
我的意思是在shell脚本里来执行,不是手工在命令行下执行
#3
可以在脚本里这样写:
su - user <123456
123456就是user的密码,
< 是输入流重定向符号
su - user <123456
123456就是user的密码,
< 是输入流重定向符号
#4
这种方法不行
ksh sss
A file or directory in the path name does not exist.
sss: bes%123: 0403-016 Cannot find or open the file.
ksh sss
A file or directory in the path name does not exist.
sss: bes%123: 0403-016 Cannot find or open the file.
#5
#!/bin/sh
savetty=`stty -g`
printf "username: "
read username
printf "password: "
stty -echo
read password
stty $savetty
echo
savetty=`stty -g`
printf "username: "
read username
printf "password: "
stty -echo
read password
stty $savetty
echo
#6
#!/bin/sh
su='su'
printf "username: "
read username
$su $username
echo
su='su'
printf "username: "
read username
$su $username
echo
#1
直接输入就行了,输入密码时,你本身是看不见的
test@linux-58hm:~> su - root
Password:
在后面输入密码就行了!
test@linux-58hm:~> su - root
Password:
在后面输入密码就行了!
#2
我的意思是在shell脚本里来执行,不是手工在命令行下执行
#3
可以在脚本里这样写:
su - user <123456
123456就是user的密码,
< 是输入流重定向符号
su - user <123456
123456就是user的密码,
< 是输入流重定向符号
#4
这种方法不行
ksh sss
A file or directory in the path name does not exist.
sss: bes%123: 0403-016 Cannot find or open the file.
ksh sss
A file or directory in the path name does not exist.
sss: bes%123: 0403-016 Cannot find or open the file.
#5
#!/bin/sh
savetty=`stty -g`
printf "username: "
read username
printf "password: "
stty -echo
read password
stty $savetty
echo
savetty=`stty -g`
printf "username: "
read username
printf "password: "
stty -echo
read password
stty $savetty
echo
#6
#!/bin/sh
su='su'
printf "username: "
read username
$su $username
echo
su='su'
printf "username: "
read username
$su $username
echo