From 4a98685c75045ab401b45ffdc12210b8871e7e6b Mon Sep 17 00:00:00 2001 From: david Date: Mon, 12 Oct 2015 22:46:45 +0200 Subject: [PATCH] changed bandwidth.sh --- bandwidth.sh | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/bandwidth.sh b/bandwidth.sh index 4168b92..f31d7fa 100755 --- a/bandwidth.sh +++ b/bandwidth.sh @@ -15,6 +15,7 @@ sshpath="/tmp" localpath="/tmp" file=$RANDOM size=10 #MB +silent=1 # config if [ $# -ne 0 ]; then @@ -24,9 +25,13 @@ if [ $# -ne 0 ]; then echo "too much arguments. exiting." exit 1 fi - echo "using custom server. ($sshuser@$sshserver)" + if [ $silent -ne 1 ]; then + echo "using custom server. ($sshuser@$sshserver)" + fi else - echo "using default server. ($sshuser@$sshserver)" + if [ $silent -ne 1 ]; then + echo "using default server. ($sshuser@$sshserver)" + fi fi # preflight @@ -47,7 +52,9 @@ if [[ $? -ne 0 ]]; then fi # create file -echo "creating $size MB file." +if [ $silent -ne 1 ]; then + echo "creating $size MB file." +fi dd if=/dev/zero of=$localpath/$file bs=$(($size*1024*1024)) count=1 &> /dev/null if [[ $? -ne 0 ]]; then @@ -56,7 +63,9 @@ if [[ $? -ne 0 ]]; then fi # upload file -echo "uploading file to $sshserver" +if [ $silent -ne 1 ]; then + echo "uploading file to $sshserver" +fi scp -v $localpath/$file $sshuser@$sshserver:$sshpath/$file &> $localpath/bandwidth_scplogup if [ $? -ne 0 ]; then echo "error while uploading file. exiting." @@ -66,10 +75,10 @@ if [ $? -ne 0 ]; then rm $localpath/$file if [[ $? -ne 0 ]]; then echo "cannot delete local file. exiting. ($localpath/$file) - you must fix this!!" - exit 1 else - echo "local file has been deleted." - exit 0 + if [ $silent -ne 1 ]; then + echo "local file has been deleted." + fi fi exit 1 @@ -80,7 +89,9 @@ echo "UPLOAD: $(($result * 8 / 1024)) kbit/s" rm $localpath/bandwidth_scplogup # download file -echo "downloading file from $sshserver." +if [ $silent -ne 1 ]; then + echo "downloading file from $sshserver." +fi scp -v $sshuser@$sshserver:$sshpath/$file $localpath/$file &> $localpath/bandwidth_scplogdown if [ $? -ne 0 ]; then echo "error while downloading file. exiting." @@ -92,7 +103,9 @@ if [ $? -ne 0 ]; then echo "cannot remove remote file. ($sshpath/$file) - you must fix this!!" sleep 5 else - echo "remote file removed." + if [ $silent -ne 1 ]; then + echo "remote file removed." + fi fi exit 1 @@ -108,7 +121,9 @@ if [[ $? -ne 0 ]]; then echo "cannot remove remote file. ($sshpath/$file) - you must fix this!!" sleep 5 else - echo "remote file removed." + if [ $silent -ne 1 ]; then + echo "remote file removed." + fi fi # remove local file @@ -117,10 +132,13 @@ if [[ $? -ne 0 ]]; then echo "cannot delete local file. exiting. ($localpath/$file) - you must fix this!!" exit 1 else - echo "local file has been deleted." + if [ $silent -ne 1 ]; then + echo "local file has been deleted." + fi exit 0 fi - -echo "all done. exiting." +if [ $silent -ne 1 ]; then + echo "all done. exiting." +fi exit 0