Created
March 1, 2014 05:22
-
-
Save BrianTheCoder/9285637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILE=$1 | |
HOSTNAME=$2 | |
USER=cfeduke | |
SPLIT_SIZE=3145728 # bytes, 3 MiB (1024*1024*3) | |
SCP_MAX_COUNT=4 # no. of maximum scps at once | |
cp $FILE /tmp | |
cd /tmp | |
FILE=$(basename $FILE) | |
split -b$SPLIT_SIZE $FILE file-part- | |
scp_count=0 | |
for part in file-part-*; do | |
scp -B "$part" $HOSTNAME:~ & | |
scp_count=$(($scp_count+1)) | |
if [ "$scp_count" -gt $SCP_MAX_COUNT ]; then | |
wait | |
$scp_count=0 | |
fi | |
done | |
if [ "$scp_count" -gt 0 ]; then | |
wait | |
fi | |
ssh -o "BatchMode yes" -t $HOSTNAME "cat /home/$USER/file-part-* >> /home/$USER/$FILE && rm /home/$USER/file-part-*" | |
rm file-part-* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment