Create directories in stagging and informatica server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create directories in stagging and informatica server
# 1  
Old 03-05-2012
Java Create directories in stagging and informatica server

I have a function in bash script to create dir and subdir
Code:
function mkdir_stage ( )
		{
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/ 
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/archivefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/dropbox
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/logfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/lookupfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/maestro
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/parameterfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/rejectfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/scriptfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/sqlfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/stagefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/targetfiles
			chmod -R 777 /webdata/ecif/etl/$Env/$projectname/
		}		
	function mkdir_informatica ( )
		{	
			mkdir -p /$Env/ecif/etl/$projectname
			mkdir -p /$Env/ecif/etl/$projectname/logfiles
			mkdir -p /$Env/ecif/etl/$projectname/dropbox
			mkdir -p /$Env/ecif/etl/$projectname/sourcefiles
			mkdir -p /$Env/ecif/etl/$projectname/scriptfiles
			mkdir -p /$Env/ecif/etl/$projectname/parameterfiles
			mkdir -p /$Env/ecif/etl/$projectname/archivefiles
			mkdir -p /$Env/ecif/etl/$projectname/targetfiles
			mkdir -p /$Env/ecif/etl/$projectname/maestro
			mkdir -p /$Env/ecif/etl/$projectname/sqlfiles
			mkdir -p /$Env/ecif/etl/$projectname/rejectfiles
			mkdir -p /$Env/ecif/etl/$projectname/lookupfiles
			mkdir -p /$Env/ecif/etl/$projectname/stagefiles
		       chmod -R 775 /$Env/ecif/etl/$projectname/
		       chmod -R 777 /$Env/ecif/etl/$projectname/dropbox
		}

But i want to reduce this further , Can someone please advice me .Thanks

Last edited by Franklin52; 03-06-2012 at 03:04 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 03-05-2012
How about something like this?

Code:
mkproj_dirs() {
  mkdir -p "$1"
  cd "$1"  &&
  mkdir archivefiles dropbox logfiles lookupfiles maestro parameterfiles rejectfiles scriptfiles  sqlfiles stagefiles targetfiles &&
  chmod 775 . &&
  chmod 777 dropbox
}

mkproj_dirs "/webdata/ecif/etl/$Env/$projectname/"
mkproj_dirs "/$Env/ecif/etl/$projectname"

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 03-05-2012
I am testing this functions in my script and get back to you ,Thanks for reply

---------- Post updated at 04:21 PM ---------- Previous update was at 04:14 PM ----------

This is my complete script ::

Code:
#!/bin/bash 
	echo " Script for creating new project in informatica"
	echo "  ***********************************************************"
	echo " First creating stagging area for new project"
	echo "  ************************************************************"
	echo "Enter the project name:"
	read proj_name
	export projectname=$proj_name
	echo "**************************************************************"
	echo " Select the Enviornment"
	echo "Choose Environment: (1-5)"
	echo "  1  -DEV/DEVL"
	echo "  2  -TEST/ALPHA"
	echo "  3  -PREPROD/BETA"
	echo "  4  -PT/SUPP"
	echo "  5  -PROD/VOL"
	echo "  *************************************************************"
	echo ""
	read Env
	export Env=$Env
	echo "***************************************************************"
	echo "Create directories in stagging and informatica server"
	echo "  *************************************************************"
	case $Env in
        1) 	export Env=devl
			export User=ecifetld
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/archivefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/dropbox
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/logfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/lookupfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/maestro
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/parameterfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/rejectfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/scriptfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/sqlfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/stagefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/targetfiles
			chmod -R 777 /webdata/ecif/etl/$Env/$projectname/
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/logfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/dropbox"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/sourcefiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/scriptfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/parameterfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/archivefiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/targetfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/maestro" 
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/sqlfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/rejectfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/lookupfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/stagefiles"
			ssh $User@boom.nwie.net "chmod -R 775 /$Env/ecif/etl/$projectname/"
			ssh $User@boom.nwie.net "chmod -R 777 /$Env/ecif/etl/$projectname/dropbox"
		;;
		2)	export Env=alpha
			export User=ecifetla
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/archivefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/dropbox
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/logfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/lookupfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/maestro
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/parameterfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/rejectfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/scriptfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/sqlfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/stagefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/targetfiles
			chmod -R 777 /webdata/ecif/etl/$Env/$projectname/
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/logfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/dropbox"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/sourcefiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/scriptfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/parameterfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/archivefiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/targetfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/maestro" 
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/sqlfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/rejectfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/lookupfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/stagefiles"
			ssh $User@boom.nwie.net "chmod -R 775 /$Env/ecif/etl/$projectname/"
			ssh $User@boom.nwie.net "chmod -R 777 /$Env/ecif/etl/$projectname/dropbox"
		;;
		3) 	export Env=beta
			export User=ecifetlb
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/archivefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/dropbox
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/logfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/lookupfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/maestro
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/parameterfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/rejectfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/scriptfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/sqlfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/stagefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/targetfiles
			ls -ltr  /webdata/ecif/etl/$Env/$projectname/
			chmod -R 777 /webdata/ecif/etl/$Env/$projectname/
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/logfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/dropbox"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/sourcefiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/scriptfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/parameterfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/archivefiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/targetfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/maestro" 
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/sqlfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/rejectfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/lookupfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/stagefiles"
			ssh $User@boom.nwie.net "chmod -R 775 /$Env/ecif/etl/$projectname/"
			ssh $User@boom.nwie.net "chmod -R 777 /$Env/ecif/etl/$projectname/dropbox"	
			ssh $User@boom.nwie.net "ls -ltr  /$Env/ecif/etl/$projectname/dropbox"
		;;
		4) 	export Env=supp
			export User=ecifetls
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/archivefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/dropbox
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/logfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/lookupfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/maestro
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/parameterfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/rejectfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/scriptfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/sqlfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/stagefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/targetfiles
			chmod -R 777 /webdata/ecif/etl/$Env/$projectname/
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/logfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/dropbox"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/sourcefiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/scriptfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/parameterfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/archivefiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/targetfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/maestro" 
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/sqlfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/rejectfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/lookupfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/stagefiles"
			ssh $User@boom.nwie.net "chmod -R 775 /$Env/ecif/etl/$projectname/"
			ssh $User@boom.nwie.net "chmod -R 777 /$Env/ecif/etl/$projectname/dropbox"	
		;;
		5) 	export Env=vol
			export User=ecifetlp
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/archivefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/dropbox
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/logfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/lookupfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/maestro
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/parameterfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/rejectfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/scriptfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/sqlfiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/stagefiles
			mkdir -p  /webdata/ecif/etl/$Env/$projectname/targetfiles
			chmod -R 777 /webdata/ecif/etl/$Env/$projectname/
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/logfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/dropbox"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/sourcefiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/scriptfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/parameterfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/archivefiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/targetfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/maestro" 
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/sqlfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/rejectfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/lookupfiles"
			ssh $User@boom.nwie.net "mkdir -p /$Env/ecif/etl/$projectname/stagefiles"
			ssh $User@boom.nwie.net "chmod -R 775 /$Env/ecif/etl/$projectname/"
			ssh $User@boom.nwie.net "chmod -R 777 /$Env/ecif/etl/$projectname/dropbox"	
		;;
	esac	
	echo " This complete creation of New Informatica directories kindy request permission change thru ITTL for Infromatica unix directories as below "
	echo " devl = eiccdevl:ecifetld "
	echo " alpha = eicctest:ecifetla "
	echo " beta	= eiccpprd:ecifetlb"
	echo " supp = eicctest:ecifetls"
	echo " vol = eiccpprd:ecifetlp"
	echo "**************************************************************************************"


Last edited by pludi; 03-06-2012 at 05:03 AM..
# 4  
Old 03-05-2012
Yeah... calling ssh 300 times, to do 300 mkdir calls is a bit of a waste.

Instead of hardcoding all the paths in the script, I'd make a tarball. That will preserve permissions and let you bundle everything in one call.
I'd run this script once:

Code:
mkdir /tmp/skel
pushd /tmp/skel
mkdir -p archivefiles dropbox logfiles lookupfiles maestro parameterfiles rejectfiles scriptfiles sqlfiles stagefiles targetfiles
chmod -R 775 /tmp/skel
tar -cf ~/skel-775.tar -C /tmp/skel .
chmod -R 777 /tmp/skel
tar -cf ~/skel-777.tar -C /tmp/skel .
popd
rm -Rf /tmp/skel

Then, whenever you want to make that whole slew of directories:

Code:
mkdir -p /path/to/$Env/$Projectname/
tar -C /path/to/$Env/$Projectname/ -xf ~/skel-775.tar

It even works over ssh, and should be tons faster:

Code:
ssh username@host mkdir -p /path/to/$Env/$Projectname ';' tar -C /path/to/$Env/$Projectname -xf - < ~/skel-775.tar

I question the need for 777 permissions at all, really. That's a silly idea in general, giving the entire universe write-access to your directories.

Last edited by Corona688; 03-05-2012 at 05:37 PM..
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 03-06-2012
Permission 777 is mandatory from app prespective as dropbox is the place any app can put there data. Thanks for the script
# 6  
Old 03-06-2012
Then 777 the dropbox, not the entire folder. The whole universe doesn't need write-access to everything just to write to the dropbox.

Better yet, find out what application's doing the dropping and give it permissions without giving the whole universe permissions.
# 7  
Old 03-06-2012
after testing mkprojs_dirs function it works fine in local but throughs an error for ssh .

Code:
Create directories in stagging and informatica server
  *************************************************************
Password:
ksh: mkproj_dirs:  not found

Remote sever is solaris ... Any suggestions

Last edited by Scott; 03-07-2012 at 11:20 AM.. Reason: Code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to create automated Directories

Hi, On serverB i wish to have a script that creates ONLY & EXACTLY the same folder structure that i provide on ServerA. Thus if serverA has a folder "Output" under /opt/app/Output and has the below folders under Output Output Output/logs Output/reciever Output/data... (11 Replies)
Discussion started by: mohtashims
11 Replies

2. UNIX for Dummies Questions & Answers

Create 2 directories in one command

Hi how can i create 2 directories in two different directories ($HOME and $PWD) with 1 command? dir 1 in $HOME and dir2 in $PWD (2 Replies)
Discussion started by: chinababy
2 Replies

3. Shell Programming and Scripting

Create duplicate directories with same permissions

Hi all, I need to create duplicate directories and sub directories (only the directories not the files or file contents) with the same permissions. Can some one guide me in doing this. I could able to create but here the permissions should be the same how can i do this in linux. Thanks in... (5 Replies)
Discussion started by: Olivia
5 Replies

4. Shell Programming and Scripting

UNIX script to check file and start the informatica server

Hi Rockers, I hope u r dng good one. I have a one question is in unix with informatica . I need a unix script to check whether particular file exists in the folder , If it means we have a informatica server , so we can start the informatica server by accessing that file. Every week we have... (0 Replies)
Discussion started by: gurukrishnan
0 Replies

5. Shell Programming and Scripting

check if multiple directories exist else create missing directories

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. UNIX for Dummies Questions & Answers

Want to create 3 different new directories under the same path

Hi, Iam new to UNIX...My requirement is to create 3 dir as an hierarchy under /var/opt/temip.The output should be /var/opt/temip/GP_Int/GPTTS/AUTO. I have tried the following script...But only GP_int folder is getting created and not other folders...Can someone help??? #!/usr/bin/ksh #script... (1 Reply)
Discussion started by: Llb
1 Replies

7. UNIX for Dummies Questions & Answers

How to create shotcuts to the directories

Hi, I need your help in writing shortcuts to my directories. So that I can go into the directories with the help of shortcuts. For example: there is a directory called /home/java/webapps/project1 I want to give a shortcut as project1 . So whenever I have give cd project 1 from command line ... (3 Replies)
Discussion started by: TonySolarisAdmi
3 Replies

8. UNIX for Dummies Questions & Answers

copying directories from NT server to Unix server (solaris 5.8)

I need to copy around 30 directories (each directory include one or more text file(s)) from NT server to Unix server at one go. For doing this what are the privillages i should have in both NT and Unix server. Please let me know which command i can use in shell prompt. TIA. (4 Replies)
Discussion started by: jhmr7
4 Replies

9. Programming

Using a C program to create directories in UNIX

Aloha, I'm attempting to use a C program to create directories and then use a system call to have another program write .dat files into that directory. I understand that I could use the "system("mkdir directory_name")" function however, I would like my program to create a new directory each time... (3 Replies)
Discussion started by: aloha_boi
3 Replies

10. UNIX for Dummies Questions & Answers

How to create directories

Hi... Can any1 help me by telling me the way to create multiple directories using single command.... to create 1 directory.. mkdir is used.... :D but how to create multiple direcs. like 4 direc. i tried .... $ mkdir a; mkdir b; mkdir c; mkdir d But its 4 commands in a single... (3 Replies)
Discussion started by: abishekmag
3 Replies
Login or Register to Ask a Question

Featured Tech Videos