Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use a script to cd... 5

Status
Not open for further replies.

AdamCoombs

Technical User
May 22, 2002
51
GB
Hello!

I am writing a script which searches a flat text file for a job number and if it exisits the last thing the script need to do is cd the user to the dir.
trouble being, if i put a "cd" command in the script it doesn't actually take the user to the dir. I understand why its not working, i just dont know a way round it to fix it.
any ideas?

Cheers
Adam
 
One method would be to run the script in the current shell (i.e don't let it spawn a child to run the script). To do this you "source" the script rather than run it. So insead of typing

scriptname

at the command line, you'd say

. scriptname

Greg.
 
Check out my FAQ . I just posted it 6-Aug
Unix Scripting FAQ
ksh Inter-process comm's

Using Signal and TWO-WAY pipe to cd login shell from another script

 
I second SamBones - good stuff!

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
A third red star for this excellent memo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top