We help IT Professionals succeed at work.

Scripts moving copying etc

bluez
bluez asked
on
Hi guys,
Firstly can you point me in the right direction for learning scripts in Unix
Secondly: I have some files on a CDROM I need to cut a cd from this.  I need a script which will copy the files to for eg /program/bin and rename the files from SDPOP.DOS to sdpop (this is eg only not actual file name)
I want to check for path statements, some machines will have the /u or /usr file system
I also want to back up existing files before being overwritten, and do I need to chmod and chown after the copy?

Many thanks.
Simon.
Comment
Watch Question

Commented:
1) What type of scripts?

2) a) "man cp"
   b) rename do a "man mv"
   c) what do you want to check in your path?
   d) why do you think you have to do a chmod/chown ?

Why do you need a script to copy the files from the CD. If it is a one time action you should do it manually ...

======
Werner

Author

Commented:
okay

We run some financial software, updates are sent to our customers. They have to be in lower case format and copied to /usr/msoft/bin.  When I get them they are in uppercase.
I seem to remember a script which will convert the case
The files are owned by multi001 hence chown.
and have 667 chmod
Also I want the tar xv8 command to run from the script.
to summarize
a, copy and change case
b, test copy grep perhaps ?
The final result should enable #./cdinst for eg.
Many Thanks
simon
Commented:
&^&^*(&)(%^&(* They locked my out, now the script is gone ...

Try again:

#! /usr/bin/ksh -p

cp <your source>/* /usr/msoft/bin

cd /usr/msoft/bin

ls | while read line
do
   mv $line `echo $line | tr 'A-Z' 'a-z'`
done

chown xxx.yyy *
chmod zzz *
##############################################

Be careful, the chown requires you to be 'root'!
I don't know what you want to use, I chose ksh to do the work. This is certainly not the perfect script, but depending on what you want to check, it should be easy to add to the script.

======
Werner

I don't know what you want to do with the tar ... I guess you want to tar these files: just add the tar at the end.

Author

Commented:
Great
Maybe I confused you with the tar bit
I think your script covers what I want to do Although the line cp <your source> maybe points to my tar question.
I suppose i could add the line
tar xvf /dev/cd0/<path< /mnt
mnt then being my source
the cd is laid out like this
spr1.0.32001/premier/os5/*
Am I correct
regards
Simon.

Commented:
Simon

Not quite ...
tar is raw format, you have to mount your cdrom first before you can do anything to it. There should be an entry in your /etc/filesystems file for your cdrom.

You do something like:
>mount /cdrom
Now you have accese to the filesystem on your cdrom.
>tar xvf /cdrom/<path> /usr/msoft/bin

will do the untar and the copy for you ...

I am not sure what is mount on /mnt ... is that your cdrom?

======
Werner

Author

Commented:
Werner

Thanks for your help, this works fine for what I want to acheive

Best Regards
Simon.

Author

Commented:
Werner

Thanks, this works fine for what I want to acheive

Best Regards
Simon.

Commented:
Glad to be helpful!
But apparently there is something missing, since you only gave me a B. Anything I forgot to explain?

======
Werner

Author

Commented:
How do I upgrade your score
I clicked on the wrong radio button

Explore More ContentExplore courses, solutions, and other research materials related to this topic.