Linux上的scp协议不可用错误

时间:2017-03-27 02:49:58

标签: linux shell ssh scp

我正在尝试将Windows文件复制到linux,但是scp命令总是看到'Protocol not available',下面是我的代码:

#!/bin/bash
client_IP='192.168.0.47'
windows_log_folder='E:\project\robot_framework\第一个测试项目\logs'
argfile_path='E:\project\robot_framework\第一个测试项目\logs\argfile.txt'
time_folder=`date +%Y-%m-%T`
echo ${time_folder}
base_path=$1
echo $base_path
log_folder="${base_path}/logs/${time_folder}"
mkdir "${log_folder}"
echo "${log_folder}"
echo "baimng.zhang@${client_IP}:${argfile_path}"
scp -p baiming.zhang@${client_IP}:${argfile_path} '${log_folder}'
ssh baiming.zhang@${client_IP} "pybot.bat --argumentfile ${argfile_path} E:\project\robot_framework\第一个测试项目" #works fine

files=`ssh baiming.zhang@${client_IP} "dir /b /a:-D ${windows_log_folder}"`
for file in $files
do
   path="${windows_log_folder}\\${file}"
   echo $path
   scp -p baiming.zhang@${client_IP}:${path} '${log_folder}' #**error appears  in this line**
done

the .splice() method

1 个答案:

答案 0 :(得分:1)

我从windows命令得到的文件名中有一个空格,我使用下面的代码修剪文件名,然后它工作正常。

for file in $files
do
    new_file="$(echo -e "${file}" | tr -d '[:space:]')"
    path=${folder}${new_file}
    path="${windows_log_folder}\\${new_file}"
    echo "try to copy ${path} to ${log_folder}"
    scp -p baiming.zhang@${client_IP}:${path} ${log_folder}
done