1
1
Fork 0

changed bandwidth.sh

This commit is contained in:
david 2015-10-12 21:53:57 +02:00
parent f79c4fdf0e
commit d3aeed67b6
1 changed files with 13 additions and 4 deletions

View File

@ -46,18 +46,27 @@ fi
# upload file
echo "uploading file to $sshserver"
scp -v $localpath/$file $sshuser@$sshserver:$sshpath/$file &> $localpath/bandwidth_scplogup
if [ $? -eq 0 ]; then
echo upload was successful
if [ $? -ne 0 ]; then
echo "error while uploading file. exiting."
echo "there might be information in the scp log. ($localpath/bandwidth_scplogup)"
exit 1
fi
result=$(cat $localpath/bandwidth_scplogup | grep "Bytes per second" | awk '{print $5}' | sed 's/\,//')
echo "upload (bytes/s): $result"
result=$(echo $result | sed 's/\..*//')
echo "upload (kbit/s): $(($result * 8 / 1024))"
rm $localpath/bandwidth_scplogup
# download file
echo "downloading file from $sshserver."
scp -v $sshuser@$sshserver:$sshpath/$file $localpath/$file &> $localpath/bandwidth_scplogdown
if [ $? -ne 0 ]; then
echo "error while downloading file. exiting."
echo "there might be information in the scp log. ($localpath/bandwidth_scplogdown)"
exit 1
fi
result=$(cat $localpath/bandwidth_scplogdown | grep "Bytes per second" | awk '{print $7}' | sed 's/\,//')
echo "download (bytes/s): $result"
result=$(echo $result | sed 's/\..*//')
echo "download (kbit/s): $(($result * 8 / 1024))"
rm $localpath/bandwidth_scplogdown
# remove remote file