我已经使用ssh -t key_gen选项使得sftp密码更less,并且不再显示提示input密码,但是当我在sftp会话中执行的命令如下所示在shell脚本中执行时,它们不会被执行相反,我只是得到了sftp的提示
#!/bin/sh username=$1 ipaddr=$2 external_path=$3 extension=$4 sftp $username@$ipaddr cd $external_path get *.$extension exit Result sftp>
没有别的
请告诉我如何实现这一点,期望的实用程序是在我的机器上,但SFTP不支持-b选项
谢谢,Priyanka
sftp用户名@ ipaddress将有sftp进入交互模式。 (这就是为什么你得到一个sftp样式提示)
sftp手册页
由于您使用的是sftp可编程性,因此您希望以非交互模式使用它。
sftp $username@$ipaddr:$external_path/filename #this would work except you need your wildcard * to be expanded echo "get *" | sftp $username@$ipaddr:$external_path/ #This will work since you are piping the command get * into sftp. #* gets expanded by sftp and matching files in $external_path #Are transfered to your current directory.