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 *
.
.
.
.
.
.
.
.

Pls put all these commands in a script file and change the permission to execute mode, it should work fine...

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.

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

so your command above to change directory

cd /home/user409/public_html/test

becomes

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..

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

#!/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 "*"

ok, to get the user dir/name for the permissions try

userid=`echo $userdir | awk 'BEGIN {FS="/"} {print $3}'`

so after using the cd command, your chown comand becomes

chown -R $userid:$userid *

or as above (Im to slow lol)

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

ok.. thank you..
works well.

it printed error

Hi,

COuld u please tell the location of source.txt file

deleted

Not enough to go on for me to help you.