Step by Step Script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Step by Step Script
# 1  
Old 11-17-2003
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  
Old 11-17-2003
Hi,

If you leave your script that way, it will do what you pretend.
# 3  
Old 11-17-2003
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  
Old 11-18-2003
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  
Old 11-18-2003
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  
Old 11-18-2003
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  
Old 11-18-2003
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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. What is on Your Mind?

Slowly Removing Bold Font Style - Step-by-Step

FYI, I'm slowly removing a lot of the bold font-styles from titles of discussions, forum titles, etc I'm not removing bold for the entire site because we do need bold from time to time, especially in posts and sometimes in other places. However, the original forum style had way too much... (3 Replies)
Discussion started by: Neo
3 Replies

2. UNIX for Advanced & Expert Users

Test shell script step by step?

Hi to all, I don't know if someone has done sometime a MS Excel Macro, that allows us to press F8 over the code to see step by step, to mention something, how is running the code, which values take the variables, if some loop is executing correct or where a error occurs, and some other... (7 Replies)
Discussion started by: Ophiuchus
7 Replies

3. Linux

May you explain step by step where and how I will add pseudo code

Thank all of you. May you explain step by step where and how I will add pseudo code Note : I have Linux 2.6.24-26-server on x86_64 dears kindly help me (3 Replies)
Discussion started by: nonowa
3 Replies

4. Solaris

Step by step to replace Failed disk

Hi all. This may be a stupid question but here goes: I lost a disk on my Sun-Fire 480-r and want to replace it. I don't care about the data, I just need to get a new disk in. Can anyone supply me with step by step procedure please. I am not an expert by any means and it is a dev box so I... (1 Reply)
Discussion started by: jamie_collins
1 Replies

5. UNIX for Dummies Questions & Answers

looking for step by step emacs c++ debug tutorial

Hello all i was searching the net for simple but effective tutorial to show me how debug c++ in emacs with not much luck. im not new to unix but new to emacs , i looking for tutorial that shows how to debug ( if possible ) c++ programs . LIike IDE suppose to , break points step in/out variable... (0 Replies)
Discussion started by: umen
0 Replies

6. Shell Programming and Scripting

works step by step on command line but not in script

Hi all, The following script is fine when I work via command line m=1 c=0 while do echo $m gnokii --getsms IN $m > out.txt; m=`expr $m + 1`; cat out.txt >> message_log; ############ read first crap< <(sed -n '/Text:/{n;p;}' out.txt); read message< <(sed -n '/Text:/{n;p;}'... (2 Replies)
Discussion started by: whamchaxed
2 Replies

7. UNIX for Dummies Questions & Answers

Step by step Installation of Unix SCO 2.1

I am new to unix and server at my job crashed due to hardware problem. I'm now opted to install sco unix on a new server - could anybody help me with the steps I need to take (pretty old machine) Thanks & Regards Nancy :( (0 Replies)
Discussion started by: nensee7
0 Replies
Login or Register to Ask a Question