script sourcing problem (ksh)

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers script sourcing problem (ksh)
# 1  
Old 09-20-2007
Bug script sourcing problem (ksh)

I have a script "" in /tmp which has exit 0 as its last line

when I run this script from /tmp/xyz/ script as

. ../

then the script executes but the control doesn't return to script for subsequent commands in

but if I invoke the from inside the as


then the control


if the script is in /tmp directory and I invoke the script from script as

. ./

then the control returns back to with out problems

isn't it strange?

I mean . ./ works but . ../ doesn't
I am trying to understand the script sourcing and this is breaking my head.

Please help

Thank you
# 2  
Old 09-20-2007
Originally Posted by rakeshou
isn't it strange?
No, it's doing exactly what it's told. "exit 0" terminates the process. When you call it ../ it is running as a child process and correctly terminates.

When you run it using . it runs in the same process and happily terminates that.
# 3  
Old 09-21-2007
I am trying to figure out this sourcing stuff, but can't find documentation for it online.

Where does this look

. ../ (parent directory?)

versus this

. ./ (current directory?)

What does the initial '.' mean? Is it the command to look for something?
# 4  
Old 09-21-2007
And is it possible to run a script that calls another script 2 directories above, but still refer to a child directory of the original one?

top directory
SBCS directory
Version directory (main script that calls generic script from top directory and needs to run stuff from Tar directory)
Tar directory (where untarred scripts/files are)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Resume parent shell after sourcing another script

#! /bin/ksh echo "b4 set exit as return" alias exit=return echo "call second" . ./ echo "after second" #. ./ unalias exit echo "ho lanciato il terzo" =================// echo "in scond" exit ==============// the above code works in k... (2 Replies)
Discussion started by: mprakasheee
2 Replies

2. Shell Programming and Scripting

Sourcing Env file with eval works with ksh but not BASH

Hi, I am running this on Redhat 5.10 I have a simple test script called which has the following contents and it uses the BASH shebang. ------------------------------------------------------------- #!/bin/bash eval `/tmp/ /tmp/envfile.txt` echo "TESTPATH=$TESTPATH" ... (28 Replies)
Discussion started by: waavman
28 Replies

3. UNIX for Advanced & Expert Users

Dot sourcing differences in ksh, AIX vs Linux vs Solaris

Why does dot sourcing of ksh functions behave so differently between AIX, Solaris, and Linux? How can I make Linux behave the way I want in the test I show below? I have a library of interdependent functions I have developed and use in ksh in AIX. They also run in Solaris. Now I am migrating... (9 Replies)
Discussion started by: charles_n_may
9 Replies

4. Shell Programming and Scripting

Sourcing variables from another script

My manager required that i keep the hostnames and username and password in a separate file when creating my sftp script. (Don't mention passwords and sftp...I've talk to him about this several times) I have a list of hostnames that have to be read in a loop in my main script. I don't know... (3 Replies)
Discussion started by: MJCreations
3 Replies

5. Shell Programming and Scripting

$1 stays set after sourcing shell script.

ok, so I have a shell script that can be called using the first argument ($1) or not. This argument is a word (Tim for example) and not an actual flag (-x for example). If I call the script with an argument and call the same script without one, it believes that I provided an argument. Note here... (2 Replies)
Discussion started by: mrwatkin
2 Replies

6. UNIX for Dummies Questions & Answers

Problem with xterm & tcsh & sourcing a script in a single command

Hi friends, I have a script that sets the env variable path based on different conditions. Now the new path variable setting should not done in the same terminal or same shell. Only a new terminal or new shell should have the new path env variable set. I am able to do this only as follows: >cd... (1 Reply)
Discussion started by: sowmya005
1 Replies

7. UNIX for Dummies Questions & Answers

word too long..problem while sourcing .cshrc

I am setting my PATH & LD_LIBRARY_PATH through .cshrc file while sourcing it on a old shell i am getting the error word too long .and the changes which i anm doing doesn't get updated . i am in a multi user environment so the only way to do the changes only for my shell is to do it that way. ... (1 Reply)
Discussion started by: mobydick
1 Replies

8. Shell Programming and Scripting

Maintain full path of a script in a var when sourcing it from a different script

Hi All, I've searched through the forum for a solution to this problem, but I haven't found anything. I have 2 script files that are in different directories. My first script, let's call it "/one/two/" looks like this: #!/bin/sh IN_DIR=`dirname $0` CUR_DIR=`pwd` cd $IN_DIR... (4 Replies)
Discussion started by: mrbluegreen
4 Replies

9. Shell Programming and Scripting

Ksh problem in script

Hi I made a small script which uses ksh. When i run the script then i get the following error However when i run each of the commands on the commandline they get executed and provide the desired output. i cant figure out why the script is not running. Kindly Help Thanks in... (3 Replies)
Discussion started by: PradeepRed
3 Replies

10. Shell Programming and Scripting

Simple ksh script problem

This is a search script that I have developed. It finds the records that I look for. However the only thing I want the program to do now is to display a message such as 'Not Found' to appear when a record is not found. So far when a search doesn't display a record, the screen is blank. ... (14 Replies)
Discussion started by: Warrior232
14 Replies
Login or Register to Ask a Question