在写bash时遇到一个问题,从远程scp文件到本地,需要输入密码,如何自动实现该过程?
#!/bin/bash#file_name: expect_1.shsrc_host=192.168.1.103src_pwd=tom@ethersrc_path=/home/chi/server2.csrc_user=chiexpect -c “spawn scp ${src_user}@${src_host}:${src_path} .expect “password:”send “${src_pwd}r”expect eof”[chi@yitai01 ~]$ ./expect_1.sh spawn scp chi@192.168.1.103:/home/chi/server2.c .Address 192.168.1.103 maps to yitai02, but this does not map back to the address – POSSIBLE BREAKIN ATTEMPT!chi@192.168.1.103’s password: server2.c 100% 1969 1.9KB/s 00:00 看到了吧,不用手工输入密码输入,jiu ke yi copy.
源代码图片:

4.jpg
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27042095/viewspace-745587/,如需转载,请注明出处,否则将追究法律责任。
主题测试文章,只做测试使用。发布者:布吉卡,转转请注明出处:http://www.cxybcw.com/196089.html