: I noticed that even if you do a cd inside a Korn-shell script,
: upon exit from the shell you will still return to the dir whence
: you came.
Because child processes cannot change their parent. When you
execute a script, you are spawning a new (child) process.
: Is there any way you can go to some other dir when U exit from
: the shell ???
You can 'source' my_korn_script thusly:
. my_korn_script
--
Tad McClellan, Logistics Specialist (IETMs and SGML guy)
Interesting trivia: If you took all the sand in North Africa and spread
it out... it would cover the Sahara desert.
The general rule is that children cannot change the environment of theirQuote:>Hi:
>I noticed that even if you do a cd inside a Korn-shell script,
>upon exit from the shell you will still return to the dir whence
>you came.
>Is there any way you can go to some other dir when U exit from
>the shell ???
>Newbie
You can, however, simulate this behavior by starting the script with the exec
command, which causes the process started by the script to overlay that of
the parent (interactive) shell, rather than forking as usual.
For example:
2 barnyard> cat trial # not a Useless Use Of Cat(tm) :-)
#!/bin/csh
cd /
csh -i
3 barnyard> pwd
/LocalUsers/tmc
4 barnyard> exec trial
1 barnyard> pwd # now in the interactive shell started from script.
/
--
************************************************************************
Terry R. McConnell Mathematics/215 Carnegie/Syracuse, N.Y. 13244-1150
************************************************************************
1. How can process cd to a dir and stay there when exits
Can anyone suggest a way for a process to cd to a dir & stay there when the \
process exits.
I have a ksh solution using an alias, a script & the program, but I'd like
to do it just with a program, or at least a script & program than will work
under csh & ksh.
Any ideas gratefully accepted.
2. How to print all man pages ?
3. cd-ing to a dir using a process, then staying there on exit.
4. Batch FTP
5. How to cd to dir and stay there in Bourne shell script
6. Printer Lexmark 2030 inkjet
7. cd-ing and staying there in a shell script
8. Can yoy IP masqerade Lotus Notes?
9. dropping CD does not exit shell on ttya
10. Staying in the last current directory following exit
11. Want manpage to stay after I exit it
12. exit status from remote shell to local shell