Sponsored Content
Top Forums Shell Programming and Scripting Script that creates directory structure Post 302596424 by colinwilson1303 on Tuesday 7th of February 2012 10:33:09 AM
Old 02-07-2012
Script that creates directory structure

Hi All,

I have a script that does daily checks on my storage environment and is run from an AIX host.

The script currently works great but I have been changing and updating bits of it to make it easier for my lesser colleagues to understand Smilie

However now with the updates I have made I have a problem. The thing is where the problem is was created by a UNIX scriptor who has now left and there is no one to help troubleshoot the command:

Problem is with creating a directory structure and my variables for creating this directory structure are:

Code:
 
_DATE_DIR="`date +%m"_"%b"_"%Y`"
_DATE_DAILY="`date +%d"."%b"."%Y`"
_DIRECTORY_PATH="/home/xxxxx/CAPACITY/REPORT/DAILY_CHECKS-VMAX/${_DATE_DIR}"
_LOG_FILE="$_DIRECTORY_PATH/${_DATE_DAILY}_Daily_Checks"


The directory structure is created using the following command and is the one command in the whole script I do not fully understand or are able to troubleshoot:

Code:
 
#MAKE DIRECTORY STRUCTURE IF IT DOES NOT EXIST
if [[ ! -d ${_DIRECTORY_PATH} ]]
then
 mkdir -p ${_DIRECTORY_PATH}
fi

when I run the script I get the following output:

Code:
 
+ date +%m_%b_%Y
_DATE_DIR=02_Feb_2012
+ date +%d.%b.%Y
_DATE_DAILY=07.Feb.2012
_DIRECTORY_PATH=/home/isoscwi/CAPACITY/REPORT/DAILY_CHECKS-VMAX/02_Feb_2012
_LOG_FILE=/home/xxxxx/CAPACITY/REPORT/DAILY_CHECKS-VMAX/02_Feb_2012/07.Feb.2012_Daily_Checks
+ [[ ! -d /home/xxxxx/CAPACITY/REPORT/DAILY_CHECKS-VMAX/02_Feb_2012 ]]
./new_daily_script: [[: not found
+ echo
./new_daily_script: /home/xxxxx/CAPACITY/REPORT/DAILY_CHECKS-VMAX/02_Feb_2012/07.Feb.2012_Daily_Checks: cannot create

I am sure this is something simple but I cannot see it myself. The "create the directory stucture" is what the UNIX guy created.

Any ideas on how I can fix this issue?

Cheers
Col

Last edited by colinwilson1303; 02-07-2012 at 11:51 AM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copying a Directory Structure to a new structure

Hi all Is it possible to copy a structure of a directory only. e.g. I have a file with the following entries that is a result of a find :- /dir1/dir2/file.dbf /dir1/dir2/dir3/file1.dbf /dir1/file.dbf I want to copy these to a directory and keep the structure however starting at a new dir... (8 Replies)
Discussion started by: jhansrod
8 Replies

2. Shell Programming and Scripting

Need script to make big directory structure

Hi, I'm a novice and I'd like to make a directory structure with a hundred or so folders. I've tried mkdir /foo/foo1/etc... mkdir /foo/foo2/etc mkdir /foo/foo3/etc mkdir /foo/foo4/etc ...but it appends '@' to each folder name and then fails on the subdirectories. Is it better to use a... (2 Replies)
Discussion started by: kamur
2 Replies

3. UNIX for Advanced & Expert Users

MV files from one directory structure(multiple level) to other directory structure

Hi, I am trying to write a script that will move all the files from source directory structure(multiple levels might exist) to destination directory structure. If a sub folder is source doesnot exist in destination then I have to skip and goto next level. I also need to delete the files in... (4 Replies)
Discussion started by: srmadab
4 Replies

4. Shell Programming and Scripting

Need help in Directory Structure

I have writen the following code to show the dirctory structure. Can any body help me for using the recursive function in this code? echo "-(0)" echo "$HOME-(1)" cd ~ set * for i in `ls $HOME` do if then echo ".....${i}" cd... (5 Replies)
Discussion started by: murtaza
5 Replies

5. Shell Programming and Scripting

Script to remove all empty files within the directory structure?

Hi I need to write a shell script which basically searches for all the empty files within the directory structure, lists them before asking the user to confirm if they would like to delete them. If the user deletes the file then a notice would appear confirming the file is deleted. I've be... (5 Replies)
Discussion started by: cat123
5 Replies

6. UNIX for Dummies Questions & Answers

Directory Structure

Hi... I have a directory which has multiple directories and sub directories inside... what command should i use to get a list of all these directories, without the filenames.... (2 Replies)
Discussion started by: saharookiedba
2 Replies

7. Shell Programming and Scripting

Shell script for a writing the directory structure to a file

Hi All, I am new user of shell scripting has come up with a problem. that I have a directory structure like : Home | |--------A | |----trunk | |-------A_0_1/ | | | |-------A_0_2/ | |--------B | ... (6 Replies)
Discussion started by: bhaskar_m
6 Replies

8. Shell Programming and Scripting

printing a directory structure

Hey everyone I am just trying print a directory structure but I am not getting the desired output. I am using AIX. Script : input file contains : TNP\\ECOM\\test\\1 input_file=folders.txt cat $input_file | while read line do echo $line done (3 Replies)
Discussion started by: rocker_me2002
3 Replies

9. Shell Programming and Scripting

Create Directory structure

Hello ; ) again Now I have my file like this : DIR2/DIR3 DIR2 DIR2/DIR3/DIR4/DIR5 I am looking for help to create a loop that will create the directory structure. I need something like this : If "DIR2" does not exist > Create IF "DIR2" exist already > check if onther "DIR"... (5 Replies)
Discussion started by: Aswex
5 Replies
Test::Script(3) 					User Contributed Perl Documentation					   Test::Script(3)

NAME
Test::Script - Basic cross-platform tests for scripts DESCRIPTION
The intent of this module is to provide a series of basic tests for 80% of the testing you will need to do for scripts in the script (or bin as is also commonly used) paths of your Perl distribution. Further, it aims to provide this functionality with perfect platform-compatibility, and in a way that is as unobtrusive as possible. That is, if the program works on a platform, then Test::Script should always work on that platform as well. Anything less than 100% is considered unacceptable. In doing so, it is hoped that Test::Script can become a module that you can safely make a dependency of all your modules, without risking that your module won't on some platform because of the dependency. Where a clash exists between wanting more functionality and maintaining platform safety, this module will err on the side of platform safety. FUNCTIONS
script_compiles script_compiles( 'script/foo.pl', 'Main script compiles' ); The "script_compiles" test calls the script with "perl -c script.pl", and checks that it returns without error. The path it should be passed is a relative unix-format script name. This will be localised when running "perl -c" and if the test fails the local name used will be shown in the diagnostic output. Note also that the test will be run with the same perl interpreter that is running the test script (and not with the default system perl). This will also be shown in the diagnostic output on failure. script_runs script_runs( 'script/foo.pl', 'Main script runs' ); The "script_runs" test executes the script with "perl script.pl" and checks that it returns success. The path it should be passed is a relative unix-format script name. This will be localised when running "perl -c" and if the test fails the local name used will be shown in the diagnostic output. The test will be run with the same perl interpreter that is running the test script (and not with the default system perl). This will also be shown in the diagnostic output on failure. SUPPORT
All bugs should be filed via the bug tracker at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Script <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Script> For other issues, or commercial enhancement and support, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
prove, <http://ali.as/> COPYRIGHT
Copyright 2006 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.16.2 2009-11-23 Test::Script(3)
All times are GMT -4. The time now is 07:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy