Customized copy.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Customized copy.
# 1  
Old 02-25-2010
Customized copy.

HI guys,

I'm working on a code with the following specs:

1. Retrieving files with a particular extensions from a location specified by the users.
2. Copying those files to user specified location
i) but i need to pause copy if the network is busy
ii) and the copy process must start automatically when network traffic is optimal
3. provide undo-copy function
4.I need to maintain a log for all the activities.

to an extent, I've managed first two specs, and may also be able to work on the log...but the network part and undo is a little difficult..I'm a novice at Unix, esp at HP-UX. I'd really appreciate any help i could get...

Code:
#!/bin/sh
echo "

enter the source folder:"
read lcmfolder
echo "

enter the destination folder:"
read lcm2folder
find $lcmfolder -name "*.dat" | cut -f 1 -d ".">foo1
find $lcmfolder -name "*.txt" | cut -f 1 -d ".">foo2
sort -n  foo1 > f1
sort -n  foo2 > f2
if diff f1 f2
then
echo "

 All relevant files present\n\n Files ready for transfer

 "
else
echo "

 Check Status: some files listed above are missing

"
fi>verlog.txt
find ./lcm -name '*.txt' -type f \
  -exec sh -c 'exec cp -f "$@" ./lcm2' find-copy {} +
find ./lcm -name '*.dat' -type f \
  -exec sh -c 'exec cp -f "$@" ./lcm2' find-copy {} +

i'm not sure how i can control network activity...leads on that will be helpful.
# 2  
Old 02-26-2010
whoa...can someone atleast post an alternative approach....or an opinion about the code...something...
# 3  
Old 02-28-2010
1. lcm2folder is not used in your script.

2. rewirte the middle part, no need to generate temp files.

Code:
#!/bin/sh
echo "

enter the source folder:"
read lcmfolder
echo "

enter the destination folder:"
read lcm2folder

for datfile in `find $lcmfolder -name "*.dat" -type f`
do
    txtfile=`echo $datfile|sed 's/dat$/txt/'`
    if [ ! -e $txtfile ] ; then
        echo "

             Check Status: file $txtfile listed above are missing

             "
        exit 1
fi

echo "

 All relevant files present\n\n Files ready for transfer

"

find ./lcm -name '*.txt' -type f \
  -exec sh -c 'exec cp -f "$@" ./lcm2' find-copy {} +
find ./lcm -name '*.dat' -type f \
  -exec sh -c 'exec cp -f "$@" ./lcm2' find-copy {} +


Last edited by rdcwayx; 02-28-2010 at 10:59 PM..
# 4  
Old 03-01-2010
That's more sensible...thanks..
[actually..lcm2-the copy destination is the same as lcm2folder, but I've forgotten to update the code before posting.]
....any ideas on copying while checking for network interruption? Can i use secure copy and ping the receiver before each transfer?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Customized text searches by using grep

I tried to ease text searches so made a customized grep: g () { if then i= for s in $2 do i="$i --include=*.$s" done else i='--include=*.txt --include=*.ini --include=*.*sh --include=*.c* --include=*.h --include=*.js --include=*.reg' fi grep -P -e \'$1\' -r "$i" } but I... (3 Replies)
Discussion started by: abdulbadii
3 Replies

2. Red Hat

Customized boot log messages

Hi all Many years ago, I found online this script that was incredibly funny and I had blogged it Unfortunately because of my poor record-keeping, I seem to have lost the shell script Would somebody be kind enough to tell me how to replicate this? Thank you! (0 Replies)
Discussion started by: hedkandi
0 Replies

3. Red Hat

Unable to create customized multipath device

Hi, I am testing on iSCSI + multipath, where i have one iSCSI lun assigned to one server. mpatha (1IET 00010001) dm-2 IET,VIRTUAL-DISK size=100M features='0' hwhandler='0' wp=rw |-+- policy='round-robin 0' prio=1 status=active | `- 2:0:0:1 sda 8:0 active ready running `-+-... (6 Replies)
Discussion started by: linux.amrit
6 Replies

4. Shell Programming and Scripting

Customized command excution

Hi, The below commands will be inside a KSH script and SOLARIS machine. Command-1 //Executes in 10s,5s,..5mins,etc TIMER = Look for Command-1 execution status - IF finished in 25secs move to next command in the script IF NOT kill above command and move to next command. Command-2 Any... (9 Replies)
Discussion started by: penqueen
9 Replies

5. Programming

Passing arguments to customized makefile

Hello, How to pass arguments to make thru command line? Have read this and that threads, but still not clear. My customized Makefile as: # convert_program.mk: run: bash bash_srcipt.sh clean: rm ${OUT_PATH}/result.txtWhat I intend is to run like this: $ make -f convert_progam.mk... (4 Replies)
Discussion started by: yifangt
4 Replies

6. Ubuntu

Need help in making bootable USB flash with customized 12.04

I'd like to make bootable USB flash with 12.04 desktop on it with some additional packages and customizations, such as added language. What I tried so far - I went through pendrivelinux.com ISO to USB program and have working bootable USB with 12.04 desktop on it. The problem is all my changes... (8 Replies)
Discussion started by: migurus
8 Replies

7. Ubuntu

Create a customized ubunto automated installtion cd

Hi 1- I want to create a cd or dvd of ubunto , that include a lot of installed packages entered by me . 2- automated installion (just enter the cd )and install by it self . (3 Replies)
Discussion started by: rashed
3 Replies

8. Forum Support Area for Unregistered Users & Account Problems

customized username?

Hi i have registered but my username is set to default value ( my email). can i change this ? (2 Replies)
Discussion started by: customizeemai
2 Replies

9. Shell Programming and Scripting

customized shell for specific users

Hi there I have an SFTP over Solaris as well it runs Samba. I need some users (outsiders) to use my SFTP facility as well to use the Samba. However i don't want them do anything else except file transferring via SFTP or Samba. I was thinking to customize their Shell so that they would not run... (1 Reply)
Discussion started by: Time_Racer
1 Replies

10. Shell Programming and Scripting

Can nmon be customized?

Hi, my name is Steve Ngai from Malaysia. This is my first post. Hope to learn more about Unix from this forum. My first question is can nmon be customized? When I run nmon, I need to manually type c to see CPU usage, then m for memory usage. Can I pass it some nmon option to automatically see... (2 Replies)
Discussion started by: ngaisteve1
2 Replies
Login or Register to Ask a Question