I have to design a file transfer system. The file transfers must run under a specific, non root, user and the files which need to be sent may not be owned by that user. What I want to do is something like
but I'm having problems writing 'getperms'. I've been looking at something like
but there must be a better way. Any ideas?
Ceci n'est pas une signature
Columb Healy
Code:
FPERM=$(getperms input_file)
chmod 666 input_file
su - txuser -c "sendfile input_file"
chmod $FPERM input_file
Code:
getperms ()
{
pstring=$(ls -l $1|awk '{print $1}')
PT1=0
PT2=0
PT3=0
[[ (echo $pstring|cut -c2) = '-' ]] || (( PT1 += 4 ))
[[ (echo $pstring|cut -c3) = '-' ]] || (( PT1 += 2 ))
[[ (echo $pstring|cut -c4) = '-' ]] || (( PT1 += 1 ))
[[ (echo $pstring|cut -c5) = '-' ]] || (( PT2 += 4 ))
[[ (echo $pstring|cut -c6) = '-' ]] || (( PT2 += 2 ))
[[ (echo $pstring|cut -c7) = '-' ]] || (( PT2 += 1 ))
[[ (echo $pstring|cut -c8) = '-' ]] || (( PT3 += 4 ))
[[ (echo $pstring|cut -c9) = '-' ]] || (( PT3 += 2 ))
[[ (echo $pstring|cut -c10) = '-' ]] || (( PT3 += 1 ))
echo $PT1$PT2$PT3
}
Ceci n'est pas une signature
Columb Healy