-
calculating write speed
Try this & report its shortcomings , if you can ?Posted 07-25-2013 at 07:58 AM by sumeet inani -
calculating write speed
Here is my latest try that works
EXCEPT
(1)wild card * asterisk not allowed in source folder
(2)also you have to mention device name in target - nothing else
(3)check the locaion of bash before running script
Code:#!/usr/bin/bash counter=0 sum=0 which bc 2> /dev/null if [ "$?" -eq 1 ] then mode="simple" else mode="accurate" fi echo we began at $(date) monitor_drive=sdb1 number_of_argument=$# if [ "$1" = "--help" ] then echo USAGE echo "./smartcopy.sh source-dir <sd##>" we assume sdb1 exit fi full_command=$@ #echo $full_command if [ "$number_of_argument" -gt 2 ] then echo defaults overridden # monitor_drive=$3 monitor_drive="${@: -1}" fi echo we-will-monitor-$monitor_drive mountpoint=$(df | grep -i $monitor_drive | awk '{ print $NF }') echo whose mount point is $mountpoint source_dest=$(echo $full_command | sed 's/ [[:alnum:]]*$//') echo we will run cp -r \"$source_dest\" $mountpoint cp -r "$source_dest" $mountpoint & processid=$! echo PID is $processid echo format is data-rate of last 10 seconds in KBps , MBps , average so far in KBps while true do tzero=$(df | grep -i $monitor_drive | awk '{print $3}') #echo tzero is $tzero sleep 10 tten=$(df | grep -i $monitor_drive | awk '{print $3}') #echo tten is $tten diff=$((tten-tzero)) counter=$(($counter + 1)) #echo difference is $diff if [ "$mode" = "simple" ] then mbps=$((diff/10240)) kbps=$((diff/10)) sum=$(($sum+$kbps)) avg=$(($sum/$counter)) echo -e "$kbps KBps , $mbps MBps\t$avg KBps" else mbps=$(echo "scale=2;$diff/10240"|bc -l) kbps=$(echo "scale=0;$diff/10"|bc -l) sum=$(echo "$sum+$kbps" | bc -l) avg=$(echo "scale=0;$sum/$counter"|bc -l) # echo -e "$kbps KBps , $mbps MBps\t$avg KBps" # awk -v kbps=$kbps -v mbps=$mbps avg=$avg '{ printf "%-10s %-10s %-20s\n", kbps, mbps, avg}' echo "$kbps $mbps $avg" | awk '{ printf "%-10s %-10s %-10s\n", $1, $2, $3}' fi if [ "$2" != "no" ] then kill -0 $processid 2> /dev/null if [ "$?" -eq 1 ] then echo cp process complete/killed . Bye . exit fi fi done echo we end at $(date) if [ -z "$SECONDS" ]; then echo "SECONDS variable not present so cannot report time elapsed"; else echo "time elapsed is '$SECONDS'"; fi
Posted 07-25-2013 at 07:57 AM by sumeet inani -
calculating write speed
here is updated one which gets rid of finding pid of process as copying process is started inside script
Code:#!/bin/bash counter=0 sum=0 which bc 2> /dev/null if [ "$?" -eq 1 ] then mode="simple" else mode="accurate" fi echo we began at $(date) monitor_drive=sdb1 number_of_argument=$# if [ "$1" = "--help" ] then echo USAGE echo "./general source-dir target-dir <sd##>" we assume sdb1 exit fi cp -r $1 $2 & if [ "$number_of_argument" -gt 2 ] then echo defaults overridden monitor_drive=$3 fi echo we-will-monitor-$monitor_drive mountpoint=$(df | grep -i $monitor_drive | awk '{ print $NF }') echo whose mount point is $mountpoint processid=$! echo PID is $processid echo format is data-rate of last 10 seconds in KBps , MBps , average so far in KBps while true do tzero=$(df | grep -i $monitor_drive | awk '{print $3}') #echo tzero is $tzero sleep 10 tten=$(df | grep -i $monitor_drive | awk '{print $3}') #echo tten is $tten diff=$((tten-tzero)) counter=$(($counter + 1)) #echo difference is $diff if [ "$mode" = "simple" ] then mbps=$((diff/10240)) kbps=$((diff/10)) sum=$(($sum+$kbps)) avg=$(($sum/$counter)) echo -e "$kbps KBps , $mbps MBps\t$avg KBps" else mbps=$(echo "scale=2;$diff/10240"|bc -l) kbps=$(echo "scale=0;$diff/10"|bc -l) sum=$(echo "$sum+$kbps" | bc -l) avg=$(echo "scale=0;$sum/$counter"|bc -l) # echo -e "$kbps KBps , $mbps MBps\t$avg KBps" # awk -v kbps=$kbps -v mbps=$mbps avg=$avg '{ printf "%-10s %-10s %-20s\n", kbps, mbps, avg}' echo "$kbps $mbps $avg" | awk '{ printf "%-10s %-10s %-10s\n", $1, $2, $3}' fi if [ "$2" != "no" ] then kill -0 $processid 2> /dev/null if [ "$?" -eq 1 ] then echo cp process complete/killed . Bye . exit fi fi done echo we end at $(date) if [ -z "$SECONDS" ]; then echo "SECONDS variable not present so cannot report time elapsed"; else echo "time elapsed is '$SECONDS'"; fi
./script-name.sh source-folder destination-folder sd##
sd##=the device where file is being copied(sdb1 default)
THE DRAWBACK
it expects folder-names without backslashes i.e alphanumeric only because $1 & $2 are space separated arguments.
Can you help me solve this ?Posted 07-19-2013 at 07:51 AM by sumeet inani
Updated 07-19-2013 at 07:54 AM by sumeet inani -
calculating write speed
I am going to add time elapsed & average writing speed using concept from
Code:#!/bin/bash count=1 sum=0 for i in 1 2 3 4 5 do echo "Welcome $i times" sum=$(echo "$sum+$i"|bc -l) avg=$(echo "scale=2;$sum/$i"|bc -l) echo sum so far is $sum echo avg so far is $avg done if [ -z "$SECONDS" ]; then echo "SECONDS variable not present so cannot report time elapsed"; else echo "time elapsed is '$SECONDS'"; fi
Posted 07-17-2013 at 07:11 AM by sumeet inani
Updated 07-17-2013 at 07:15 AM by sumeet inani -
grabbing videos from youtube
Well, yes, such method sure is funny and simplePosted 12-11-2011 at 02:31 AM by Web31337 -
changing order in grub2
Now I have debian 6.0.2 in which I played with file "30_otheros"Posted 11-26-2011 at 08:16 AM by sumeet inani -
java in debian 6
I thought about saving that page for offline checking java but not possiblePosted 05-28-2011 at 10:42 AM by sumeet inani -
dos programming
Code:template file name (write end to exit) :-fn2 URL:-http://download843.mediafire.com/gnyvblcgnrmg/cexz23f5t9s3t1b/Finding+Nemo+-+Sha2lba.Com_By_Sam.part2.rar 03:59 PM time to schedule job :-16:00 Added a new job with job ID = 24 file name (write end to exit) :-fn3 URL:-http://download843.mediafire.com/070j0q671ygg/avmtzv8e3t182vt/Finding+Nemo+-+Sha2lba.Com_By_Sam.part3.rar 03:59 PM time to schedule job :-16:00 Added a new job with job ID = 25 file name (write end to exit) :-fn4 URL:-http://download1334.mediafire.com/8d253gjlg1hg/3a487e6yqin7b54/Finding+Nemo+-+Sha2lba.Com_By_Sam.part4.rar 03:59 PM time to schedule job :-16:01 Cannot create a file when that file already exists. file name (write end to exit) :-end
can you spot error in template.bat ?Posted 05-17-2011 at 05:33 AM by sumeet inani -
how to compile c program in linux
A habit should be developed to compile always with:
Code:gcc c_program.c -Wall -Wextra
Posted 03-15-2011 at 04:30 AM by Aquarius_Girl