LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 09-16-2011, 01:39 AM   #1
dav_y2k
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...

#!/bin/sh

dir1="/Users/admin/Desktop/copydownfolder/"

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

IFS=$'\n'

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

do
if [ ! -d $L ]; then

exit 1
fi

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

done

format2="%-1s\n"
printf "$format2"


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

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

There seems to be a space in the source:
Code:
/Volumes/RAID 1/copydownfolder/copyupfolder
Try change the cp command to:
Code:
cp "$L" "$dir1"
BTW: Are the execution quotes really needed around the cp command?
Code:
`cp "$L" "$dir1"`
vs
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, 01:52 AM   #3
pallinger
LQ Newbie
 
Registered: Feb 2009
Posts: 4

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

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

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


Reply



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 03:23 PM
file copy in script help needed pinga123 Linux - Newbie 5 04-10-2010 01:16 AM
How to capture elapsed time for a file copy command SteveInTallyFL Linux - Newbie 3 01-25-2010 01:08 PM
Make KDE/Konqueror preserve time, ownership on file copy tisource Linux - Software 2 06-27-2006 01:23 PM
Howto Monitor elapsed time in a shell script rkrijger Linux - Software 2 03-11-2004 08:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:54 PM.

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