简体   繁体   中英

Enter Password through bourne shell script when asked by the command without expect

I am writing a bourne shell script for the openwrt firware where I want to copy my files from router to linux machine. when i do

scp /etc/clients.txt shah@192.168.1.2:/home/shah/

from inside the router's openwrt firmware, it asks me to give the password. I want to give this password from within the script because this file needs to be copied after every 2 seconds. How can I do this without using expect?

You can try to use sshpass tool but you will need to provide a password in clear text in your script. If that is not a problem you should use it.

sshpass -p 'password'  scp /etc/clients.txt shah@192.168.1.2:/home/shah/

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