首页 > 解决方案 > 使用 bash 脚本从服务器中查找和 SCP 文件

问题描述

以下是我的 bash 脚本:

#!/bin/bash
echo "directory: $1"
echo "filename: $2"
echo "username: $3"
echo "destination: $4"
echo "host: $5"
SEARCH=$2*
echo "Search: $SEARCH"
for i in 'ssh $3@$5 find $1 -type f -name SEARCH'
do
    echo $PWD
    FILE=$i
    echo "FILE= $FILE"
    scp $3@$5:$FILE $4
done

这是我的输出:

directory: **Correct Directory**
filename: **Correct Filename**
username: **Correct username**
destination: ./STORAGE
host: **Correct Host**
Search: filename*
/Users/ranjanasinha/ransinha/POS-INVESTIGATION
FILE= ssh $3@$5 find $1 -type f -name $SEARCH
scp: ssh: No such file or directory
cp: $3@$5: No such file or directory
cp: find: No such file or directory
cp: $1: No such file or directory
cp: -type: No such file or directory
cp: f: No such file or directory
cp: -name: No such file or directory

我期待 FILE 有找到的文件名。我的问题是为什么“我”没有找到找到的文件?命令有什么问题?

标签: bashfindscp

解决方案


推荐阅读