cp, chown, untar


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cp, chown, untar
# 8  
Old 04-17-2009
Code:
#!/bin/ksh
 
while read line
do
 usr=${$line%/public_html/*}       # assumes directory after user is always "/public_html"
 usr=${usr#/home/}                 # assumes user directory is always in /home"
 untar special.tar.gz -xvfz $line
 chown -R $usr:$usr $line          # should be no need to cd if last directory is okay 
 chmod -R 755 $line                # to be owned by $usr.  If not use cd "$line"
done < source.txt                  # command and replace "$line" in chown & chmod
                                   # with "*"


Last edited by rwuerth; 04-17-2009 at 11:42 AM..
# 9  
Old 04-17-2009
ok, to get the user dir/name for the permissions try
Code:
userid=`echo $userdir | awk 'BEGIN {FS="/"} {print $3}'`

so after using the cd command, your chown comand becomes
Code:
chown -R $userid:$userid *

or as above (Im to slow lol)
# 10  
Old 04-17-2009
Hi,

while read line
do
untar special.tar.gz -xvfz $line
cd $line
USROWN=`echo $line | cut -d"/" -f3`
chown -R $USROWN:$USROWN *
chmod -R 755 *
done < source.txt
# 11  
Old 04-17-2009
ok.. thank you..
works well.

Last edited by topic32428285; 04-18-2009 at 10:18 AM..
# 12  
Old 04-17-2009
Quote:
Originally Posted by rwuerth
Code:
#!/bin/ksh

while read line
do
usr=${$line%/public_html/*} # assumes directory after user is always "/public_html"
usr=${usr#/home/} # assumes user directory is always in /home"
untar special.tar.gz -xvfz $line
chown -R $usr:$usr $line # should be no need to cd if last directory is okay
chmod -R 755 $line # to be owned by $usr. If not use cd "$line"
done < source.txt # command and replace "$line" in chown & chmod
# with "*"

it printed error

Last edited by topic32428285; 04-18-2009 at 10:18 AM..
# 13  
Old 04-17-2009
Hi,

COuld u please tell the location of source.txt file
# 14  
Old 04-17-2009
deleted

Last edited by topic32428285; 04-18-2009 at 10:19 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

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
Login or Register to Ask a Question