Skip to content

Commit 549afbb

Browse files
Create Template-multihostexec.sh
1 parent fc18ab1 commit 549afbb

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Template-multihostexec.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MULTIHOSTEXEC_HOSTLIST_FILE=template-multihost-hosts.lst
2+
nHostListCount=`grep -v "^$\|#" $MULTIHOSTEXEC_HOSTLIST_FILE 2>/dev/null | wc -l`
3+
arrHostList=`grep -v "^$\|#" $MULTIHOSTEXEC_HOSTLIST_FILE 2>/dev/null`
4+
if [ ! -s $MULTIHOSTEXEC_HOSTLIST_FILE -o ! -r $MULTIHOSTEXEC_HOSTLIST_FILE -o $nHostListCount -eq 0 ]; then
5+
echo "Error: Cannot read host file/file is empty."
6+
exit 1
7+
fi
8+
echo "Found $nHostListCount hosts."
9+
nHostIndex=0
10+
for nHost in $arrHostList
11+
do
12+
nHostIndex=`expr $nHostIndex + 1`
13+
echo "Processing [$nHostIndex of $nHostListCount] $nHost."
14+
ssh -q -T $nHost <<-'ENDSSH'
15+
ENDSSH
16+
strRemoteFileName="/some/remote-folder/*$(date +%Y%m%d).tar.gz"
17+
echo "On LOCAL - Downloading remote file $nHost:$strRemoteFileName $strRemoteFileName."
18+
scp -q $nHost:$strRemoteFileName
19+
test $? && echo "On LOCAL - File download complete!"
20+
done
21+
echo "Complete!"

0 commit comments

Comments
 (0)