<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Directory check in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007295#M98975</link>
    <description>Something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;echo "Enter Dir Name: "&lt;BR /&gt;read DIRNAME&lt;BR /&gt;if [[ -d ${DIRNAME} ]] ; then&lt;BR /&gt;  echo "Dir Exists"&lt;BR /&gt;else&lt;BR /&gt;  echo "Dir does not exist"&lt;BR /&gt;  mkdir ${DIRNAME}&lt;BR /&gt;  chmod 770 ${DIRNAME}&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;You notice I didnot chmod 777.  777 are VERY VERY VERY BAD permissions.  That means that ANYBODY on the server can royall screw up anything in that directory.</description>
    <pubDate>Fri, 06 Oct 2006 10:34:15 GMT</pubDate>
    <dc:creator>Patrick Wallek</dc:creator>
    <dc:date>2006-10-06T10:34:15Z</dc:date>
    <item>
      <title>Directory check</title>
      <link>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007294#M98974</link>
      <description>How do I check for the existence of a directory?&lt;BR /&gt;&lt;BR /&gt;Basically what I would like to do is the user inputs a name, then a script checks whether the directory exist. If it does not exist then create the directory and subdirectories. Also chmod -R 777. The script should be able to check this from any directory that it is run from.</description>
      <pubDate>Fri, 06 Oct 2006 10:18:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007294#M98974</guid>
      <dc:creator>Unix or Linux?</dc:creator>
      <dc:date>2006-10-06T10:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: Directory check</title>
      <link>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007295#M98975</link>
      <description>Something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;echo "Enter Dir Name: "&lt;BR /&gt;read DIRNAME&lt;BR /&gt;if [[ -d ${DIRNAME} ]] ; then&lt;BR /&gt;  echo "Dir Exists"&lt;BR /&gt;else&lt;BR /&gt;  echo "Dir does not exist"&lt;BR /&gt;  mkdir ${DIRNAME}&lt;BR /&gt;  chmod 770 ${DIRNAME}&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;You notice I didnot chmod 777.  777 are VERY VERY VERY BAD permissions.  That means that ANYBODY on the server can royall screw up anything in that directory.</description>
      <pubDate>Fri, 06 Oct 2006 10:34:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007295#M98975</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2006-10-06T10:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Directory check</title>
      <link>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007296#M98976</link>
      <description>First of all, to grant directories with 777 is really not secure and you use at least 775?&lt;BR /&gt;&lt;BR /&gt;Secondly, user input must contain full path otherwise you won't know where to start with&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;ls -l $1&lt;BR /&gt;if [ $? -eq 0 ] ; then&lt;BR /&gt;   echo $1 " exists"&lt;BR /&gt;else&lt;BR /&gt;   mkdir -p $1&lt;BR /&gt;   chmod -R 777 $1&lt;BR /&gt;   echo $1 " has been created"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;call it dirchk.sh&lt;BR /&gt;&lt;BR /&gt;user need to run it like "dirchk.sh /aaa/bbb/ccc"</description>
      <pubDate>Fri, 06 Oct 2006 10:37:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007296#M98976</guid>
      <dc:creator>Yang Qin_1</dc:creator>
      <dc:date>2006-10-06T10:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Directory check</title>
      <link>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007297#M98977</link>
      <description>It's rather simple:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset DNAME=""&lt;BR /&gt;typeset STAT=255&lt;BR /&gt;echo "Enter directory name: \c"&lt;BR /&gt;read DNAME&lt;BR /&gt;if [ -e "${DNAME}" ]&lt;BR /&gt;  then&lt;BR /&gt;    echo "${DNAME} already exists.] &amp;gt;&amp;amp;2&lt;BR /&gt;  else&lt;BR /&gt;    mkdir "${DNAME}"&lt;BR /&gt;    STAT=${?}&lt;BR /&gt;    if [ ${STAT} -ne 0 ]&lt;BR /&gt;      then&lt;BR /&gt;        echo "Cannot mkdir ${DNAME}; status ${STAT}." &amp;gt;72&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;I have no idea what the subdirectories should be. It should be obvious where your chmod goes but setting mode to 777 should be done only in extremely rare cases; it is a huge security hole.&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Oct 2006 10:40:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007297#M98977</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-10-06T10:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Directory check</title>
      <link>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007298#M98978</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if you use&lt;BR /&gt;&lt;BR /&gt;umask 0&lt;BR /&gt;mkdir -p -m 777 dirname&lt;BR /&gt;&lt;BR /&gt;you will get all you need (whether it makes sense to have world writable directories or not).&lt;BR /&gt;In this form you will&lt;BR /&gt;- not get an error message for existing directories&lt;BR /&gt;- an error message if the creation failes&lt;BR /&gt;- the exit status will be accordingly&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Sat, 07 Oct 2006 15:05:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007298#M98978</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-10-07T15:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Directory check</title>
      <link>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007299#M98979</link>
      <description>Another small issue: I need the directory to be created all in lowercase. So if the user enters DIR123 the directory will be created as dir123 if the directory does not already exist. &lt;BR /&gt;&lt;BR /&gt;I have tried using the tr command to no success as follows.&lt;BR /&gt;&lt;BR /&gt;LUsr=`echo $DIRNAME | tr'[:upper:]''[:lower:]'`&lt;BR /&gt;&lt;BR /&gt;What am I doing wrong here? &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I also tried the following:&lt;BR /&gt;&lt;BR /&gt;LUsr=`nawk '{print tolower($DIRNAME)}'`</description>
      <pubDate>Tue, 10 Oct 2006 11:05:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007299#M98979</guid>
      <dc:creator>Unix or Linux?</dc:creator>
      <dc:date>2006-10-10T11:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Directory check</title>
      <link>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007300#M98980</link>
      <description>Instead use the commands below...&lt;BR /&gt;&lt;BR /&gt;# echo $DIRNAME | tr [:upper:] [:lower:]&lt;BR /&gt;&lt;BR /&gt;OR&lt;BR /&gt;&lt;BR /&gt;LUsr=`echo $DIRNAME | nawk '{print tolower($0)}'`&lt;BR /&gt;&lt;BR /&gt;cheers!</description>
      <pubDate>Tue, 10 Oct 2006 11:30:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007300#M98980</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-10-10T11:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Directory check</title>
      <link>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007301#M98981</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;If you are collecting your data interactively, use 'typeset -l' to lowercase your input:&lt;BR /&gt;&lt;BR /&gt;# typeset -l NAME&lt;BR /&gt;# read   NAME&lt;BR /&gt;# echo ${NAME}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 10 Oct 2006 12:06:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007301#M98981</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-10-10T12:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Directory check</title>
      <link>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007302#M98982</link>
      <description>thanks</description>
      <pubDate>Thu, 12 Oct 2006 08:20:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/directory-check/m-p/5007302#M98982</guid>
      <dc:creator>Unix or Linux?</dc:creator>
      <dc:date>2006-10-12T08:20:32Z</dc:date>
    </item>
  </channel>
</rss>

