简体   繁体   中英

Can not enter password in Shell Script

I can not enter my pass word. My shell script is here.

#!/bin/bash

expect -c "
set timeout 2
spawn ftp ${HOST}
expect \"Name\(${HOST}:root\):\"
send ${USER}\n
expect \"Password:\"
send ${PASS}\n
interact
"

I can enter user-name, but password is not work....

like this return.

spawn ftp ******
Connected to ****** (******).
220 (vsFTPd 2.2.2)
Name (******:root): ${USER}
331 Please specify the password.
Password:[root@........ bin]#

I think I send password... Could you please help me?

Thank you.

SOLVE MY QUESTION

I think it is easy for me to use this.

it is easy for me to use this.
#!/bin/sh

SERVER=$1
USER=$2
PASS=$3
FILE=$4

ftp -n <<END
open $SERVER
user $USER $PASS
cd /tmp
binary
prompt
mput $FILE
END

you have to prompt password and send it to variable


echo -n "Enter Password:" read PASS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM