Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Changing directory
Name: ravi.kumar Date: April 27, 2005 at 05:19:03 Pacific OS: Unix CPU/Ram: 256MB
Comment:
Hi, I have a directory A in my home dir, I need a script to change to dir A, after executing the script I shouldn't be in my home dir (i.e pwd should show /home dir/A) how can I do this
Name: nails Date: April 27, 2005 at 07:21:14 Pacific
Reply:
Hi:
Executing a shell script spawns a child shell. In order for your directory changes for to remain in effect once the child terminates, you must "source" the script:
. myscript.ss
For sh/ksh/bash scripts, from the command-line, that is a period, a space, and the script name.
Regards,
Nails
0
Response Number 2
Name: Luke Chi Date: April 27, 2005 at 08:41:55 Pacific
Reply:
I created many alias in my .profile file, like:
alias _o='cd $ORACLE_HOME; pwd' alias _j='cd $J2EE_HOME; pwd' alias _p='cd $APACHE_HOME; pwd' alias _b='cd $B2B_HOME; pwd' ...
then, for example $ _o $ /u01/oracle/product/10.1.0/Edge/j2ee/home
Luke Chi
0
Response Number 3
Name: ravi.kumar Date: April 27, 2005 at 22:17:34 Pacific
Summary: Answer to first question: When you run a shell script it creates it's own shell, and that is where the change directory takes place. When your program finishes it reverts back to your original shell a...
Summary: Hi, I'm using korn shell. I'm calling a simple bit of script from within a script to change directory but it's not working. The change directory script is just something like: cd <whatever director...
Summary: I have a simple script that changes directory- cd /newdirectory pwd - when I run this it seems to execute correctly, but after it executes I'm still in my original directory. I guess I'm changing dire...