Running bash file download.sh, scp
shows "no such file" error. So I try to run the command ps -efj | grep scp
, and console outputs:
love@192.168.1.105:/home/storage/static/test/res/house/res.zip_b077f446? ../logs/static/test/res/house/
A redundant question mark occurs in the file name and I think that causes the error info of "no such file". But echo $SOURCE
output is static/test/res/house/res_update.zip_61b25e4b
, no question mark.
download.sh
#!/bin/bash
FILE=love@192.168.1.105:/home/storage/
while read p; do
PART_DIR=$(echo $p | awk 'BEGIN{FS=OFS="/"}{NF--; print}')
DEST_DIR="../logs/${PART_DIR}" # directory for saving files
mkdir -p "${DEST_DIR}"
SOURCE="${FILE}${p}"
echo $SOURCE # debug, output: static/test/res/house/res_update.zip_61b25e4b
scp -P 19061 $SOURCE "${DEST_DIR}/"
done <../logs/file.txt
file.txt
static/test/res/house/res.zip_b077f446
static/test/res/house/res_update.zip_61b25e4b