Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-16-2011, 02:39 AM   #1
LQ Newbie
Registered: Apr 2005
Distribution: RedHat
Posts: 16

Rep: Reputation: 0
Script to monitor time taken to copy a File error

Dear All,
I am trying to write a script to monitor time taken to copy a File from a SAN volume to a disk on a workstation and I get the error below:

cp: cannot stat `/Volumes/RAID 1/copydownfolder/copyupfolder:': No such file or directory

I would like the script to skip any folders in the source directory. Please see the script below...



format="%-30s %-30s %-10s\n"
format1="%-1s %-1s\n"
printf "$format1" SECTION I
printf "$format" "Date and Time", "File Copy Duration", "Filename"
printf "$format" "-------------", "------------------", "-----------------------------------------------------"

## Section I


for L in $(ls /Volumes/RAID\ */copydownfolder/*)

if [ ! -d $L ]; then

exit 1

before=$(date +%s)

# commands to time go here

`cp $L $dir1`

after=$(date +%s)

elapsed_seconds=$(expr $after - $before)

printf "$format" $(date), $elapsed_seconds, $L


printf "$format2"

Thank you for your response..
Old 09-16-2011, 02:48 AM   #2
LQ Veteran
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392

There seems to be a space in the source:
/Volumes/RAID 1/copydownfolder/copyupfolder
Try change the cp command to:
cp "$L" "$dir1"
BTW: Are the execution quotes really needed around the cp command?
`cp "$L" "$dir1"`
cp "$L" "$dir1"
Another thing that could make your life a bit easier: the time command (time cp source destination)

Hope this helps.
Old 09-16-2011, 02:52 AM   #3
LQ Newbie
Registered: Feb 2009
Posts: 4

Rep: Reputation: 0
To copy only regular files (and not directories), you coud use:

find "$indir" -maxdepth 1 -type f
Also, you could use the
command on the for cycle to measure total elapsed time.

Last edited by pallinger; 09-16-2011 at 02:54 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Script to copy paste text from one file to another (overwriting part of the file) freet Programming 4 04-19-2011 04:23 PM
file copy in script help needed pinga123 Linux - Newbie 5 04-10-2010 02:16 AM
How to capture elapsed time for a file copy command SteveInTallyFL Linux - Newbie 3 01-25-2010 02:08 PM
Make KDE/Konqueror preserve time, ownership on file copy tisource Linux - Software 2 06-27-2006 02:23 PM
Howto Monitor elapsed time in a shell script rkrijger Linux - Software 2 03-11-2004 09:46 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:44 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration