我正在编写一个脚本,我试图导出一些变量,在我打印时导出我的变量后,它会在它之后打印一个额外的行.
这里我是从包含两列的csv文件中读取的.
此脚本存在于文件script.sh中,我正在执行该文件./script.sh
#!/bin/bash
while IFS="," read f1 f2
do
echo "Source IP : $f1" #it is printing without extra line
echo "Destination IP : $f2" #it is printing without extra line
export sourceIP=$f1
export destIP=$f2
ssh -t -t sjain@$f1 <
#Start copying 33KB File
echo "Destination IP Address: $destIP" # here it is printing an extra line after destIP
startTime=$(($(date '+%s%N')/1000000))
scp KB_33.txt sjain@$destIP:/home/sjain
endTime=$(($(date '+%s%N')/1000000))
printf 'Elapsed time in copying 33KB file: %s
' $((endTime-startTime))
#Write the stats to the file
echo $sourceIP','$destIP',33KB,'$((endTime-startTime)) >> report.txt
exit
ENDSSH
done < ipaddress.csv
因为我执行时出现上述问题
scp KB_33.txt sjain@$destIP:/home/sjain
它将命令分为两部分,就像这样
scp KB_33.txt sjain@$X.X.X.X
:/home/sjain
当我直接硬编码值而不是destIP时,它工作正常.
我怎样才能解决这个问题?
输入CSV文件数据
10.0.0.1,10.0.0.2