Hi all, I am just a beginner at shell scripting, but I need to make a script which: 1) hardlinks the content of a directory into another place 2) sets up the correct permissions of files in the other place I have to do this because the user of my system do a mess when they want to share some file each other. This is what I have tried: #!/bin/sh #Syntax is supposed to be link.sh <directory> case "$1" in --help) echo "Syntax is link.sh <dir>"; echo "If you want to share some files only, create the dir before this command"; exit 0 ;; *) export WHOAMI=`whoami`; mkdir /home/share/"$1"."$WHOAMI"/ ; ln ./"$1"/* /home/share/"$1"."$WHOAMI"/. ; chmod -R a+r /home/share/"$1"."$WHOAMI" ; chmod -R g-w /home/share/"$1"."$WHOAMI" ; chmod -R o-w /home/share/"$1"."$WHOAMI" ; chmod a+x /home/share/"$1"."$WHOAMI" ; #Ok, it's not very recorsive for i in /home/share/"$1".$WHOAMI/* ; do [ -d "$i" ] && \ chmod a+x "$i" ; done ; #and there is no error handling exit 0 ;; exit 0; #############END This script creates a mistake (syntax error near unexpected token exit). I cant work around it, any advice? Praise
* Praise
I am just a beginner at shell scripting, but I need to make a script which: 1) hardlinks the content of a directory into another place 2) sets up the correct permissions of files in the other place
I have to do this because the user of my system do a mess when they want to share some file each other.
Well, you maybe want to try another approach to share the files. Why not start an NFS server some place? Or use CVS? -- Mads Martin Joergensen, http://mmj.dk "Why make things difficult, when it is possible to make them cryptic and totally illogic, with just a little bit more effort." -- A. P. J.
Il 00:57, giovedì 6 dicembre 2001, Mads Martin Jørgensen ha scritto:
* Praise
[Dec 06. 2001 00:46]: I am just a beginner at shell scripting, but I need to make a script which: 1) hardlinks the content of a directory into another place 2) sets up the correct permissions of files in the other place
I have to do this because the user of my system do a mess when they want to share some file each other.
Well, you maybe want to try another approach to share the files. Why not start an NFS server some place? Or use CVS?
Let me explain my situation: there are about 20 user of my system, mainly with ssh and sftp. There are also 3 users which could use Samba (and they actually do). They need to share with eachother some files: that's easy. They only need to link their files in a common directory and adjust permission. The problem is that they do not want to do that because they are very lazy to learn new commands (they are new to linux). That's why I thought about this script. I have not looked for cvs, because I do not know it yet. I know what it is for, but it is not what I need. Praise
On Thursday 06 December 2001 01:20, Praise wrote:
Let me explain my situation: there are about 20 user of my system, mainly with ssh and sftp. There are also 3 users which could use Samba (and they actually do). They need to share with eachother some files: that's easy. They only need to link their files in a common directory and adjust permission. The problem is that they do not want to do that because they are very lazy to learn new commands (they are new to linux). How about this:
mkdir /path/to/commondir ----> the directory with the shared files chmod 2755 commondir ----> checkout 'man chmod' or somewhere groupadd commongrp ----> a group to own the dir chgrp commongrp commondir ln -s /path/to/common /home/someuser/common ----> link to user homedir for each user: usermod -G commongrp ----> addl. group... set "umask" to 002 (or 007...) ----> make new files group-accessible Ideally each user has his own group, since the umask of 007 makes his own files writeable to others. HTH Dan
* Praise (praisetazio@tiscalinet.it) [011205 15:46]:
I am just a beginner at shell scripting, but I need to make a script which: 1) hardlinks the content of a directory into another place
Only root can hardlink directories...why not just create a public directory in /home that is group writable (maybe by users or another group if not all users should be able to wirte to it) and set the sticky bit on it. -- -ckm
On Thursday 06 December 2001 00.45, Praise wrote:
Hi all,
I am just a beginner at shell scripting, but I need to make a script which: 1) hardlinks the content of a directory into another place 2) sets up the correct permissions of files in the other place
I have to do this because the user of my system do a mess when they want to share some file each other.
This is what I have tried:
#!/bin/sh #Syntax is supposed to be link.sh <directory>
case "$1" in --help) echo "Syntax is link.sh <dir>"; echo "If you want to share some files only, create the dir before this command"; exit 0 ;; *) export WHOAMI=`whoami`; mkdir /home/share/"$1"."$WHOAMI"/ ; ln ./"$1"/* /home/share/"$1"."$WHOAMI"/. ; chmod -R a+r /home/share/"$1"."$WHOAMI" ; chmod -R g-w /home/share/"$1"."$WHOAMI" ; chmod -R o-w /home/share/"$1"."$WHOAMI" ; chmod a+x /home/share/"$1"."$WHOAMI" ;
#Ok, it's not very recorsive for i in /home/share/"$1".$WHOAMI/* ; do [ -d "$i" ] && \ chmod a+x "$i" ; done ; #and there is no error handling exit 0 ;;
Somewhere around here there should probably be a line 'esac' to end the case statement.
exit 0; #############END
This script creates a mistake (syntax error near unexpected token exit). I cant work around it, any advice?
Praise
You do know you can't create hardlinks across partition boundaries, don't you? regards Anders
participants (5)
-
Anders Johansson
-
Christopher Mahmood
-
Dan Am
-
Mads Martin Jørgensen
-
Praise