Visit Our UNIX and Linux User Community


cp, chown, untar


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cp, chown, untar
# 1  
Old 04-17-2009
cp, chown, untar

hello

i want shell script.

i have a source.txt

/home/user409/public_html/test/
/home/user09876/public_html/xdsss/
/home/user9765/public_html/320xxx/
.
.
.

maybe 1000 lines

i want .

1.read a source.txt
2.untar special.tar.gz into these directory in source.txt
3.i want to change untar all files ownership rightly
4.chmod 755 untar all files .

ex)
!!!!!! first line
untar special.tar.gz -xvfz /home/user409/public_html/test/
and cd /home/user409/public_html/test
and chown -R user409:user409 *
and chmod -R 755 *


!!!!!!second line
untar special.tar.gz -xvfz /home/user09876/public_html/xdsss/
and cd /home/user09876/public_html/xdsss/
and chown -R user09876:user09876 *
and chmod -R 755 *
.
.
.
.
.
.
.
.

Last edited by topic32428285; 04-17-2009 at 09:35 AM..
# 2  
Old 04-17-2009
Pls put all these commands in a script file and change the permission to execute mode, it should work fine...
# 3  
Old 04-17-2009
Quote:
Originally Posted by Nagesh
Pls put all these commands in a script file and change the permission to execute mode, it should work fine...
it is 1000 lines ;;
# 4  
Old 04-17-2009
Quote:
Originally Posted by topic32428285
it is 1000 lines ;;
I think what was ment was put the above commands you gave into a script and read in the directories from the file, ie.

Code:
while read userdir
do
..
your commands
..
done < source.txt

so your command above to change directory
Code:
cd /home/user409/public_html/test

becomes
Code:
cd $userdir

etc.

How to strip the user dir/name is another question, sadly I cant answer at present
# 5  
Old 04-17-2009
Quote:
Originally Posted by Tag
I think what was ment was put the above commands you gave into a script and read in the directories from the file, ie.

Code:
while read userdir
do
..
your commands
..
done < source.txt

so your command above to change directory
Code:
cd /home/user409/public_html/test

becomes
Code:
cd $userdir

etc.

How to strip the user dir/name is another question, sadly I cant answer at present

How about changing ownership?
maybe untar file is root..
# 6  
Old 04-17-2009
Hi,
check this out !

while read line
do
untar special.tar.gz -xvfz $line
cd $line
chown -R user409:user409 *
chmod -R 755 *
done < source.txt
# 7  
Old 04-17-2009
Quote:
Originally Posted by abinaya
Hi,
check this out !

while read line
do
untar special.tar.gz -xvfz $line
cd $line
chown -R user409:user409 *
chmod -R 755 *
done < source.txt
no
these directory is not under user409.
each directory's ownership is different.

/home/user409/public_html/test/ ------>ownership:user409
/home/user09876/public_html/xdsss/ ------>ownership:user09876
/home/user9765/public_html/320xxx/ ------>ownership:user9765

Previous Thread | Next Thread
Test Your Knowledge in Computers #142
Difficulty: Easy
Version 4 Unix was rewritten in C in 1977.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Pls help. can't do chown ????

I am trying to change the directory to owner of Sybase. But I get permission denied. I did login as root. newd1> ls -l total 58 drwxr-xr-x 2 prod develop 5 Oct 17 06:51 bin drwxr-xr-x 2 prod develop 7 Oct 17 07:18 etc dr-xr-xr-x 1 root root 1... (15 Replies)
Discussion started by: samnyc
15 Replies

2. Solaris

chown

Hello My oracledatabase creats some xmlfiles. this files has the owner hugo. now I've a script (how runs als hugo2) and this script will insert this XMLFile into the database. But that doesn't work, because the owner of the files is wrong, and hugo has not the rights to insert this files into... (3 Replies)
Discussion started by: Street
3 Replies

3. Shell Programming and Scripting

Chown - error

I have a file fin2009_4.txt.gz in the unix ftp server. Owner of the file is: ftpusr. -rw-r--r-- 1 ftpusr sap 0 Feb 19 10:19 fin2009_4.txt.gz When I try to delete this file after copying to my home folder, I am getting the following error. rm: fin2009_4.txt.gz1: override... (4 Replies)
Discussion started by: sid1982
4 Replies

4. AIX

Trouble in chown

I'm a owner of directories or files why I can't deliver the ownership of them up to other users? (1 Reply)
Discussion started by: kang
1 Replies

5. UNIX for Dummies Questions & Answers

chown

is there a difference in chown on a file or a directory? how do i chown a directory and all the contents? (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

6. Shell Programming and Scripting

Trying to untar then chown, and chmod

I'm changing (trying to anyway) a script that will need to unrar a file, this file will create a directory with files in it. Then I need to change the owner ship and permission on that directory. Finally, I will rsync the directory to another machine. This is what I have so far. #!/bin/bash ... (1 Reply)
Discussion started by: walkerl
1 Replies

7. UNIX for Dummies Questions & Answers

reg chown

hi i wrote a script to run 'C' executable which will create a new file, after that util is completed, i have to change the file ownership to some other user. for that i used "chown" for changing the file permission in Korn script :confused:but it is throwing error is "operation... (2 Replies)
Discussion started by: ilayans
2 Replies

8. UNIX for Dummies Questions & Answers

Chgrp and Chown ???

Hi Can anybody please let me know the usage of Chgrp command with an example??? Thanks (1 Reply)
Discussion started by: skyineyes
1 Replies

9. UNIX for Advanced & Expert Users

chown issue

I have a strange problem in my Linux box (Suse). Recently I took over this box as admin even though I have no prior admin experience. Following is my issue I had following users under 'root' group initially user1 user2 user3 Since I did not like user ids under root group. I modifed these... (9 Replies)
Discussion started by: praveenkumar_l
9 Replies

10. AIX

chown

hello chown not change ownership before: 205:system ~kuku chown kuku:system ~kuku after no change 205:system ~kuku aix box can someone help me? ariec (2 Replies)
Discussion started by: ariec
2 Replies

Featured Tech Videos