我从machineA运行我的下面的
shell脚本,它将文件machineB和machineC复制到machineA.如果文件不在machineB中,那么它应该在machineC中.
下面的shell脚本会将文件复制到machineA中的TEST1和TEST2目录中.
#!/bin/bash set -e readonly TEST1=/data01/test1 readonly TEST2=/data02/test2 readonly SERVER_LOCATION=(machineB machineC) readonly FILE_LOCATION=/data/snapshot dir1=$(ssh -o "StrictHostKeyChecking no" david@${SERVER_LOCATION[0]} ls -dt1 "$FILE_LOCATION"/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] | head -n1) dir2=$(ssh -o "StrictHostKeyChecking no" david@${SERVER_LOCATION[1]} ls -dt1 "$FILE_LOCATION"/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] | head -n1) echo $dir1 echo $dir2 if [ "$dir1" = "$dir2" ] then rm -rf $TEST1/* rm -rf $TEST2/* for el in $test1_partition do scp david@${SERVER_LOCATION[0]}:$dir1/pp_monthly_9800_"$el"_200003_5.data $TEST1/. || scp david@${SERVER_LOCATION[1]}:$dir2/pp_monthly_9800_"$el"_200003_5.data $TEST1/. done for sl in $test2_partition do scp david@${SERVER_LOCATION[0]}:$dir1/pp_monthly_9800_"$sl"_200003_5.data $TEST2/. || scp david@${SERVER_LOCATION[1]}:$dir2/pp_monthly_9800_"$sl"_200003_5.data $TEST2/. done fi
目前它首先将文件从machineB和machineC复制到machineA TEST1目录,如果完成,那么只有它会将文件从machineB和machineC复制到machineA TEST2目录..有没有办法我将文件传输到TEST1和TEST2目录同时出现?
我正在运行Ubuntu 12.04