The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Taking CEP to The Next Step iBot Complex Event Processing RSS News 0 02-29-2008 06:40 PM
works step by step on command line but not in script whamchaxed Shell Programming and Scripting 2 12-06-2007 07:47 AM
Step by step Installation of Unix SCO 2.1 nensee7 UNIX for Dummies Questions & Answers 0 01-11-2007 09:22 AM
Next Step?? (Different Forum) Pls. help radith SuSE 1 09-04-2004 09:19 AM
install of sco unix step by step porikamu UNIX for Dummies Questions & Answers 1 05-27-2004 09:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-17-2003
lisafern lisafern is offline
Registered User
  
 

Join Date: Nov 2003
Posts: 5
Step by Step Script

Hello !!!

I´m really new at Unix and have to write a script to copy some files from some locations to another one.

I need to be sure that each file has finished copied before starting to copy the other one. I believe unix returns the control to a script before the command really ends.

my script is something like

cp /u/test1/file1 /backup/file1
cp /x/test2/file2 /backup/file2
cp /y/test3/file3 /backup/file3

I´m running Solaris 2.8 bourne shell.

Is there any way to ensure thet the second cp cpmmand starts after the first one really ends?

TIA

Lisandro
  #2 (permalink)  
Old 11-17-2003
jsilva's Avatar
jsilva jsilva is offline
Registered User
  
 

Join Date: Apr 2003
Posts: 169
Hi,

If you leave your script that way, it will do what you pretend.
  #3 (permalink)  
Old 11-17-2003
lisafern lisafern is offline
Registered User
  
 

Join Date: Nov 2003
Posts: 5
Jorge:

Thanks for your help.

What if I copy to a tape device? I was told that the device may return control really finiching the copy.
  #4 (permalink)  
Old 11-18-2003
jorge.ferreira jorge.ferreira is offline
Registered User
  
 

Join Date: Oct 2003
Location: Torres Novas, Portugal
Posts: 18
try this

I think that if you want to backup to a tape device, you'll need the tar command.

tar cvf(crete new job) /your_tape/device ./your_directory_to_be_copied_1 ./your_directory_to_be_copied_2

It worked for me...

Jorge Ferreira
  #5 (permalink)  
Old 11-18-2003
kduffin's Avatar
kduffin kduffin is offline Forum Advisor  
UN1X
  
 

Join Date: Nov 2003
Location: Maryland
Posts: 449
I'd be sure to check the return value of each step. As a general rule, you want to check the return value of anything that does return a value. The built-in variable $? will have a 0 for success (with a few exceptions).

Cheers,

Keith
  #6 (permalink)  
Old 11-18-2003
jorge.ferreira jorge.ferreira is offline
Registered User
  
 

Join Date: Oct 2003
Location: Torres Novas, Portugal
Posts: 18
You mean check for every directory copied?
I used the other script because i didn't found any other way to do it.
By the way, can you please tell me how can i do to "join" several directories to a backup job?
Like this

tar cvf /device ./First #This one always cvf
tar ??? /device ./Second
...

How does it return anything and how can i treat the variable?

Best Regards

Jorge Ferreira
  #7 (permalink)  
Old 11-18-2003
kduffin's Avatar
kduffin kduffin is offline Forum Advisor  
UN1X
  
 

Join Date: Nov 2003
Location: Maryland
Posts: 449
Jorge,

It would be helpful if you identify why you want to ensure a sequential order of the copies. Is this for something like an Oracle database backup where you are putting tablespaces in backup mode, then backing up member datafiles? Either way, I'd like to understand why you want to be sure that each file has finished copied before starting to copy the other one.

The cp checks can be done many ways. There is a built-in conditional that can be specified with ||, for example

cp ick1 ick9 || cp ick88 ick99 || cp ick3 success

The next operation will not be performed unless the previous is successful. The same conditional would work with tar specifying each directory. You would just have to be sure that you are specifying a non-rewinding device (ie. /dev/rmt/1mn instead of /dev/rmt/1m).

Cheers,

Keith
Closed Thread

Bookmarks

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0