![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| check if file exists in a mounted windows shared folder | jul | Shell Programming and Scripting | 2 | 05-14-2008 01:50 AM |
| How to check if a direcorty exists? | SunnyK | Shell Programming and Scripting | 2 | 11-08-2007 10:47 AM |
| check if directory exists | jerardfjay | Shell Programming and Scripting | 2 | 06-13-2005 02:26 PM |
| Check Remote Folder Exists | borncrazy | Shell Programming and Scripting | 1 | 07-12-2004 04:15 PM |
| Folder Exists | borncrazy | UNIX for Dummies Questions & Answers | 5 | 06-19-2004 01:48 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
simple check to see if a folder exists
Hi, I have cobbled together a simple script to create a Windows folder in a bunch of home folders on a mac server using the following code.
Code:
for i in /Volumes/student_data/studenthomefolders/* do u=`echo $i | cut -d/ -f5` //if [ -d $i/Windows ] //then //echo "Folder already exists for "$u" Skipping" //else echo "Making Windows Dir for "$u mkdir $i/Windows echo "Changing Ownership of Windows Directory for "$u chown $u $i/Windows echo "Setting Mode for Windows Folder for "$u chmod 700 $i/Windows done If I run the script after creating a new user it currently runs through all of them, fails to create the existing ones but still chmods and chowns them, while this is not a massive problem I would like a neater script, anyone point me in the right direction. Preferably it would silently skip existing ones and just report the new creations. Many thanks in advance |
|
||||
|
Code:
for i in /Volumes/student_data/studenthomefolders/*
do
u=`echo $i | cut -d/ -f5`
if [ ! -d $i/Windows ]; then
echo "Making Windows Dir for "$u
mkdir $i/Windows
echo "Changing Ownership of Windows Directory for "$u
chown $u $i/Windows
echo "Setting Mode for Windows Folder for "$u
chmod 700 $i/Windows
fi
done
|
|
||||
|
Many thanks, that diddn't quite work but altering it to
Code:
for i in /Volumes/student_data/studenthomefolders/*
do
u=`echo $i | cut -d/ -f5`
if [ -d $i/Windows ];
then
echo $u" Windows folder exists" >/dev/null
else
echo "Making Windows Dir for "$u
mkdir $i/Windows
echo "Changing Ownership of Windows Directory for "$u
chown $u $i/Windows
echo "Setting Mode for Windows Folder for "$u
chmod 700 $i/Windows
fi
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|