Unable to export Directory paths through Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to export Directory paths through Script
# 1  
Old 10-25-2010
Unable to export Directory paths through Script

Following is the output of .profile file -

$ cat /home/estdm2/.profile
Code:
#!/bin/ksh
set -o vi

alias l="ls -ltr"
umask 002

Following is the path setting script.

$ cat DM_ENV_VARS_NEW.ksh
Code:
#!/bin/ksh
. /home/estdm2/.profile

sEnv=$1
echo "We are in ${sEnv} environment"
echo "STEP010 - Set Environment Variables for script."
export DM_ETL_HOME=/etl/estdm2
export SCRIPT_DIR=${DM_ETL_HOME}/scripts
export BASE_LOG_DIR=${DM_ETL_HOME}/log
export LOG_DIR=${BASE_LOG_DIR}/script

When I call DM_ENV_VARS_NEW.ksh script from another script and print the variable, it prints nothing. So the export is not working properly

$ cat /etl/estdm2/dev/scripts/test.ksh
Code:
#!/bin/ksh
#
echo "Testing the script - DM_ENV_VARS.ksh"

/etl/estdm2/dev/scripts/DM_ENV_VARS_NEW.ksh DEV
echo ${DM_ETL_HOME}
echo $BASE_LOG_DIR

PHP Code:
$ /etl/estdm2/dev/scripts/test.ksh
Testing the script 
DM_ENV_VARS.ksh
We are in DEV environment
STEP010 
Set Environment Variables for script

I dont know what's going wrong with such a simple script.

I would appreciate any suggestion.

Thanks
Sumeet
# 2  
Old 10-25-2010
Code:
. /etl/estdm2/dev/scripts/DM_ENV_VARS_NEW.ksh DEV

Try preceding the line with dot-space (same as you did for sourcing .profile).
# 3  
Old 10-25-2010
It worked but can you explain how did that help. Is this "." forcing the child script to export the paths in same shell as parent script?


Thanks
Sumeet
# 4  
Old 10-26-2010
Yes - its called "sourcing".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with reading directory paths with spaces from a file

Hi I want to know how to handle the spaces in the below scenario. I have a file (CON_zip_path_1.txt) which has some directory paths with spaces in directory names . My requirement is to unzip these zip files to another path. Please see the code below and the error. CON_zip_path_1.txt... (4 Replies)
Discussion started by: paul1234
4 Replies

2. Shell Programming and Scripting

Replace directory paths in multiple files at once

I need to update about 2400 files in a directory subtree, with a new directory path inside the files I need to change this occurence in all files: /d2/R12AB/VIS/apps/tech_st/10.1.2 with this: /u01/PROD/apps/apps_st/10.1.3 I know how to change single words using "find . -type f -print0 |... (6 Replies)
Discussion started by: wicus
6 Replies

3. Shell Programming and Scripting

Awk to replace directory paths

Hi all, I have written a bash script to do a few things for my Splunk deployment, however, I am currently stuck on one part... I need to the current working directory (I collect this with `pwd`) in the script as it could in theory be run from a number of locations. I'm not that great with... (5 Replies)
Discussion started by: TauntaunHerder
5 Replies

4. UNIX for Advanced & Expert Users

Unable to export delimiter as variable to SQL

Hi, I'm using a shell wrapper to trigger a teradata sql fastexport script as follows: #!/bin/ksh export delm=`echo "\t"` fexp <<! SELECT COALESCE(TRIM(CAST(col1 AS VARCHAR(10))),'') ||'$delm'|| COALESCE(CAST(col2 AS VARCHAR(10)),'') ||'$delm'|| COALESCE(TRIM(col3),'') FROM TABLE; ... (11 Replies)
Discussion started by: sumoka
11 Replies

5. UNIX for Dummies Questions & Answers

cat a list of directory paths only to a file

Hi! I would like to funnel a series of directories and subdirectories into a text file. This is the output I would like to see from a find command: /mypath/ABC_01/VISIT_01 /mypath/ABC_01/VISIT_02 /mypath/ABC_01/VISIT_03 /mypath/ABC_02/VISIT_01 /mypath/ABC_03/VISIT_01 I've tried: find... (2 Replies)
Discussion started by: goodbenito
2 Replies

6. UNIX Desktop Questions & Answers

how to display paths of files in a directory

hi guys does anyone know how to display the file paths of the files stored within a directory at the command terminal? e.g. if i have a directory called "home", how do i display the file paths of the files inside the directory? cheers (2 Replies)
Discussion started by: Villaman69
2 Replies

7. Shell Programming and Scripting

Find Directory from array of file names with paths

I have a script that generates a variable with the location of a file and its complete path. What i want to do is to "cd" to the directory where that file is located using the path name of the file. GIS has absolutely failed me. For example when i run my script it generates a variable called... (1 Reply)
Discussion started by: Knome
1 Replies

8. Solaris

find home directory paths for all users

How to find al the user's home directories? (2 Replies)
Discussion started by: a2156z
2 Replies

9. UNIX for Dummies Questions & Answers

Unable to use mimesender to send attachments with spaces in the file names / paths

Hello, I found the mimesender multiple attachment emailing shell script in the FAQ of these forums, and I have been able to use it to send multiple files, but only if they don't have spaces in their file name or path. When I attempt to send a file with spaces in it's name, enclosed... (0 Replies)
Discussion started by: rsmorra
0 Replies

10. Solaris

need script for locked and unused user accounts in /export/home directory

Hi all, i have to need one script: 1. it will capture the unused user accounts in /export/home directory. 2. it will capture the locked user accounts in /export/home directory. Note: locked accounts will show in /etc/passwd like /bin/false --> (instead of ksh it will show false) the... (1 Reply)
Discussion started by: krishna176
1 Replies
Login or Register to Ask a Question