<?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: Scripting question - mkdir statement in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150207#M683655</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;One way to avoid surprises and quickly find problems is to have your scrip fail when a variable isn't set.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;set -u&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Another thing I like to do when doing 'mkdir's is to issue them as:&lt;BR /&gt;&lt;BR /&gt;# mkdir -p&lt;BR /&gt;&lt;BR /&gt;...such that all intermediate paths are created in one simple statement.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 13 Jan 2009 16:11:40 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2009-01-13T16:11:40Z</dc:date>
    <item>
      <title>Scripting question - mkdir statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150206#M683654</link>
      <description>All, I have a script that i am having problems with inconsistent behavior, &lt;BR /&gt;if the "TRANSCRIPT Folder" exist the script will move a file per directive, I have an IF statement that says if the Folder for this APPID does not exist mkdir the Transcripts directory before copying the file. &lt;BR /&gt;&lt;BR /&gt;I would like to ask for other eyes to see what problems exist in this script that maybe be disallowing this script to work.  The top of the script is mostly defining variable the bottom is what seems to be causing my difficulty.. Any insight or thought appreciated.. This is a homegrown document management system for one of our districts HR departments. &lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;export destpath=/mps-docs/mps-docs/applicant/&lt;BR /&gt;export source=/mps-docs/mps-docs/transcript-staging/ &lt;BR /&gt;export backuppath=/mps-docs/mps-docs/transcript-backup/&lt;BR /&gt;mv /tmp/mps_temp.log /tmp/mps_temp.log.`date +%Y%m%d`&lt;BR /&gt;touch /tmp/mps_temp.log &lt;BR /&gt;echo &amp;gt; /tmp/mps_temp.log &lt;BR /&gt;echo `mount |grep mps-docs ` &amp;gt;&amp;gt; /tmp/mps_temp.log &lt;BR /&gt;cd $source &lt;BR /&gt;for fn in `ls`&lt;BR /&gt;do&lt;BR /&gt;ls $source &amp;gt;&amp;gt; /tmp/mps_temp.log &lt;BR /&gt;echo Source Location $source &amp;gt;&amp;gt; tmp/mps_temp.log &lt;BR /&gt;echo Filename in Source Location $fn &amp;gt;&amp;gt; /tmp/mps_temp.log &lt;BR /&gt;echo Destination Path  $destpath  &amp;gt;&amp;gt; /tmp/mps_temp.log &lt;BR /&gt;&lt;BR /&gt;export distID=`echo $fn |awk -F_ '{print $1}'`&lt;BR /&gt;export appID=`echo $fn |awk -F_ '{print $2}'` &lt;BR /&gt;export docID=`echo $fn |awk -F_ '{print $3}'|cut -d. -f1` &lt;BR /&gt;export tID=`echo $fn |awk -F_ '{print $4}'|cut -d. -f1` &lt;BR /&gt;export ext=`echo $fn |awk -F_ '{print $4}'|cut -d. -f2` &lt;BR /&gt;echo $fn |cut -d. -f2 | read ext&lt;BR /&gt;&lt;BR /&gt;echo $fn &amp;gt;&amp;gt; /tmp/mps_temp.log  &lt;BR /&gt;echo $destpath$appID &amp;gt;&amp;gt; /tmp/mps_temp.log &lt;BR /&gt;ls $destpath$appID &amp;gt;&amp;gt; /tmp/mps_temp.log&lt;BR /&gt;echo $destpath$appID/Transcripts &amp;gt;&amp;gt; /tmp/mps_temp.log &lt;BR /&gt;ls $destpath$appID/Transcripts/ &amp;gt;&amp;gt; /tmp/mps_temp.log&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if [[ -z $destpath ]]; then&lt;BR /&gt;echo "ERROR: invalid distID $distID"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;while [[ -f ${destpath}/${appID}/Transcripts/${distID}_${appID}_${docID}_${tID}.${ext} ]]&lt;BR /&gt;do&lt;BR /&gt;(( docID += 1 ))&lt;BR /&gt;if (( docID &amp;gt; 99 )); then&lt;BR /&gt;echo "ERROR: docID too high!"&lt;BR /&gt;exit 2&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;#####################################################################&lt;BR /&gt;#### ADDED DOUBLE QUOTE AROUND TEST VALUE - 12-28-2008 RCM ESU#3 ####&lt;BR /&gt;#####################################################################&lt;BR /&gt;if [ -d "${destpath}/${appID}/Transcripts" ] &lt;BR /&gt;        then &lt;BR /&gt;        cp -f $fn ${destpath}/${appID}/Transcripts/${distID}_${appID}_${docID}_${tID}.${ext}&lt;BR /&gt;                echo Transcript Folder Exists and Files copies shown &amp;gt;&amp;gt; /tmp/mps_temp.log &lt;BR /&gt;                ls ${destpath}/${appID}/Transcripts &amp;gt;&amp;gt; /tmp/mps_temp.log &lt;BR /&gt;                mv ${source}${fn} ${backuppath}/&lt;BR /&gt;                echo Backup of original files moved from ${source}${fn} to  ${backuppath}/ &amp;gt;&amp;gt;/tmp/mps_temp.log &lt;BR /&gt;        else &lt;BR /&gt;                mkdir ${destpath}/${appID}/Transcripts &lt;BR /&gt;                cp -f $fn ${destpath}/${appID}/Transcripts/${distID}_${appID}_${docID}_${tID}.${ext}&lt;BR /&gt;                        echo Transcript Folder Create and Files copies shown &amp;gt;&amp;gt; /tmp/mps_temp.log &lt;BR /&gt;                        ls ${destpath}/${appID}/Transcripts &amp;gt;&amp;gt; /tmp/mps_temp.log &lt;BR /&gt;                        mv ${source}${fn} ${backuppath}/&lt;BR /&gt;                        echo Backup of original files moved from ${source}${fn} to  ${backuppath} &amp;gt;&amp;gt;/tmp/mps_temp.log &lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jan 2009 15:59:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150206#M683654</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2009-01-13T15:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question - mkdir statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150207#M683655</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;One way to avoid surprises and quickly find problems is to have your scrip fail when a variable isn't set.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;set -u&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Another thing I like to do when doing 'mkdir's is to issue them as:&lt;BR /&gt;&lt;BR /&gt;# mkdir -p&lt;BR /&gt;&lt;BR /&gt;...such that all intermediate paths are created in one simple statement.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 13 Jan 2009 16:11:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150207#M683655</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-01-13T16:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question - mkdir statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150208#M683656</link>
      <description>James, Thanks as usual, I will try both. and see if I can catch the problem in output some how. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jan 2009 16:15:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150208#M683656</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2009-01-13T16:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question - mkdir statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150209#M683657</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;I would also add that you can use perform an automatic 'chmod' to set the permissions of the directory when you make it, since I don't see an explicit 'umask' declaration in your script and thus you are at the mercy of what you inherit:&lt;BR /&gt;&lt;BR /&gt;# mkdir -p -m 775 ${mydir}/{mysubdir1}/${mysubdir2}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 13 Jan 2009 16:17:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150209#M683657</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-01-13T16:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question - mkdir statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150210#M683658</link>
      <description>so make it look as such: &lt;BR /&gt;&lt;BR /&gt;mkdir -p -m 775 ${destpath}/${appID}/Transcripts&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jan 2009 16:20:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150210#M683658</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2009-01-13T16:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question - mkdir statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150211#M683659</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; so make it look as such: &lt;BR /&gt;&lt;BR /&gt;mkdir -p -m 775 ${destpath}/${appID}/Transcripts&lt;BR /&gt;&lt;BR /&gt;Yes, that's the idea, although you may want an absolute path:&lt;BR /&gt;&lt;BR /&gt;# mkdir -p -m 775 /${destpath}/${appID}/Transcripts&lt;BR /&gt;&lt;BR /&gt;The permissions are entirely your choice, too.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jan 2009 16:28:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150211#M683659</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-01-13T16:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question - mkdir statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150212#M683660</link>
      <description>James, This script is scheduled to run as a cron I keep forgetting about full path to executables when running as cron. &lt;BR /&gt;&lt;BR /&gt;I will fix these as well Thanks for the assist.. I will monitor the outcome and close this thread accordingly.. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jan 2009 16:31:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150212#M683660</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2009-01-13T16:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question - mkdir statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150213#M683661</link>
      <description>setting the shell in '-x' will allow you to see what it is doing, great tool for troubleshooting (it's a kind of debug mode for shell scripting).</description>
      <pubDate>Thu, 15 Jan 2009 07:23:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150213#M683661</guid>
      <dc:creator>dirk dierickx</dc:creator>
      <dc:date>2009-01-15T07:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question - mkdir statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150214#M683662</link>
      <description>Thanks for the help.. I think maybe finally got this fixed.</description>
      <pubDate>Thu, 15 Jan 2009 14:23:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-mkdir-statement/m-p/5150214#M683662</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2009-01-15T14:23:02Z</dc:date>
    </item>
  </channel>
</rss>

