01-14-2009
Replace missing standard folders from home directories.
Hi, I want to develop a script to replace missing folders from home directories. These may have been deleted by the user. A standard home directory will have these folders in it and nothing else:
Desktop, Documents, Downloads, Library, Movies, Music, Pictures, Public, Sites
I also want to move anything that is not one of the standard folders listed here from the root of the home directory into ~user/Documents/ and not overwrite anything there, perhaps by appending a date or something to the file name.
If a folder is missing from the home directory, I want to replace it with one from: /System/Library/User\ Template/English.lproj/ where exists the folders used to create home directories. Then we need to change ownership so that it belongs to the user and not root.
Also, assume that every home directory name is the same as the userid, Liza Jane has userid 'janel' and her home directory is /Users/Students/janel
for user in /Users/Students/* ; do
#here is where I want to replace missing folders for example:
cp -R /System/Library/User\ Template/English.lproj/Sites $user/
chown -R $user $user/Sites
# and move anything non-standard into $user/Documents/
done
exit
Any advice would sure be appreciated.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have a script that deletes obselete users from /etc/passwd then moves their home directories to another location. After 30 days, I need to delete the home directories that were moved to the new location. I would appreciate any ideas on how to delete the directories after the 30 days? (2 Replies)
Discussion started by: munch
2 Replies
2. Solaris
I know that how to backup the home directories in sun sparc server.
Firstly, umount the filesystem,
Secondly, fsck the filesystem,
Thirdly, ufsdump the filesystem.
Anybody know how to type the full command line backup the /home directory? (1 Reply)
Discussion started by: kingsan
1 Replies
3. UNIX for Dummies Questions & Answers
Hi All,
Could someone help, am a complete beginner when it comes to UNIX. However I have been tasked with investigating automatic creation of UK unix home directories.
Is someone able to help?
Thanks in advance! (7 Replies)
Discussion started by: zainster
7 Replies
4. Shell Programming and Scripting
i have users home directories in /home
all the users have some files starting with character e
and i want to copy all these files in a folder in my (root) home
using a script
i tried the script
for i in m5
do
cd m5
cp e1* /home/pc/exam
cd ..
done
but get these... (3 Replies)
Discussion started by: pcrana
3 Replies
5. Shell Programming and Scripting
Hi ,
I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory.
how to write this in a simple script, I have made my code complex
if ; then
taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies
6. Shell Programming and Scripting
I do not know much about shell scripting so I am at a loss here. If someone can help me, that would be great!
I have two directories
/dir1
/dir2
I need to delete all files from /dir1 and that does not have a correspondent file in /dir2. It should NOT check file suffixes in /dir2 . Why?... (20 Replies)
Discussion started by: kaah
20 Replies
7. Shell Programming and Scripting
First of all, let me state that I am a windows admin.
I have a windows share mounted to /mnt/server
I need a script that will either login as sudo or perform commands with sudo rights. I need the script to copy all of the users /home folders to the mounted windows share. Now If I can... (7 Replies)
Discussion started by: EricM
7 Replies
8. HP-UX
Hi,
At my new company they use HP-UX on all the servers.
They use Serviceguard to provide different packages, which are treated as if they where seperate systems. Therefore people log into packages instead of Host, and even the home directories live in the package.
Now there are a different... (4 Replies)
Discussion started by: michas
4 Replies
9. Solaris
When I'm logging as a user(i.e., oracle), I don't find any files and folders in /home
Attached error message below, while logging...
Last login: Fri Sep 7 08:08:09 2012 from ko.domain
Could not chdir to home directory /home/oracle: No such file or directory
Sun Microsystems Inc. SunOS... (6 Replies)
Discussion started by: karthikn
6 Replies
10. Shell Programming and Scripting
Hi,
I need help in shell scripting. If someone can help me, that would be great!
Problem. I want Linux Script to compare two folders and copy missing files.
Description.
I have two directories
/dir1
/dir2
I need to copy all distinct/new/unique/missing files from /dir1 and that... (1 Reply)
Discussion started by: S.Praveen Kumar
1 Replies
MB2MD(1) General Commands Manual MB2MD(1)
NAME
mb2md -- Converts Mbox mailboxes to Maildir format.
SYNOPSIS
mb2md [-h]
mb2md [-c] [-m] [-d destdir]
mb2md [-c] [-s sourcefile] [-d destdir]
mb2md [-c] [-s sourcedir] [-l wu-mailboxlist] [-R|-f somefolder] [-d destdir] [-r strip_extension]
DESCRIPTION
mb2md Converts Mbox mailboxes to Maildir format.
OPTIONS
-h Show summary of options.
-c Use the Content-Length: headers (if present) to find the beginning of the next message. Use with caution! Results may be unreli-
able. I recommend to do a run without "-c" first and only use it if you are certain, that the mbox in question really needs the
"-c" option.
-m If this is used then the source will be the single mailbox at /var/spool/mail/blah for user blah and the destination mailbox will
be the "destdir" mailbox itself.
-s sourcedir
Directory, relative to the user's home directory, which is where the the "somefolders" directories are located. Or if directory
starts with a "/" it is taken as a absolute path, e.g. /mnt/oldmail/user _OR_ A single mbox file which will be converted to the
destdir.
-R If defined, do not skip directories found in a mailbox directory, but runs recursively into each of them, creating all wanted
folders in Maildir.
Incompatible with '-f'
-f somefolder
Directories, relative to "sourcedir" where the Mbox files are. All mailboxes in the "sourcedir" directory will be converted and
placed in the "destdir" directory. (Typically the Inbox directory which in this instance is also functioning as a folder for
other mailboxes.)
The "somefolder" directory name will be encoded into the new mailboxes' names. See the example in the USAGE file (see below).
This does not save an UW IMAP dummy message file at the start of the Mbox file. Small changes in the code could adapt it for
looking for other distinctive patterns of dummy messages too.
Don't let the source directory you give as "somefolders" contain any "."s in its name, unless you want to create subfolders from
the IMAP user's point of view. See the example in the USAGE file (see below).
Incompatible with '-R'
-d destdir
Directory where the Maildir format directories will be created. If not given, then the destination will be ~/Maildir . Typi-
cally, this is what the IMAP server sees as the Inbox and the folder for all user mailboxes. If this begins with a '/' the path
is considered to be absolute, otherwise it is relative to the users home directory.
-r strip_extension
If defined this extension will be stripped from the original mailbox file name before creating the corresponding maildir. The
extension must be given without the leading dot ("."). See the example in the USAGE file (see below).
-l WU-file
File containing the list of subscribed folders. If migrating from WU-IMAP the list of subscribed folders will be found in the
file called .mailboxlist in the users home directory. This will convert all subscribed folders for a single user:
/bin/mb2md -s mail -l .mailboxlist -R -d Maildir
and for all users in a directory as root you can do the following:
for i in *; do echo $i;su - $i -c "/bin/mb2md -s mail -l .mailboxlist -R -d Maildir";done
USAGE
Please read the USAGE documentation (zless /usr/share/doc/mb2md/USAGE.gz).
AUTHOR
This manual page was written by Noel Kothe noel@debian.org for the Debian system (but may be used by others). Permission is granted to
copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version pub-
lished by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.
MB2MD(1)