trweil@aplcen.apl.jhu.edu (Weil Timothy Robert) (06/14/90)
I'd like to be prompted after login as to which directory I'd like to be working in - Tried a simple prompting via shell script; also tried inserting same prompting in .profile (Ultrix running Korn Shell)... results were similar - a 'pwd' would indicate that I'd changed to the selected directory but UNIX kept me logged into $HOME....any other tricks to try?
gwyn@smoke.BRL.MIL (Doug Gwyn) (06/15/90)
In article <5672@aplcen.apl.jhu.edu> trweil@aplcen.apl.jhu.edu (Weil Timothy Robert) writes: >results were similar - a 'pwd' would indicate that I'd >changed to the selected directory but UNIX kept me >logged into $HOME....any other tricks to try? A "cd" in a subprocess will not affect the CWD of an ancestral process. However, your .profile is supposed to be executed in the context of the login shell, so a "cd" there should work. In fact, mine does it and it works fine.
mike@x.co.uk (Mike Moore) (06/15/90)
In article <5672@aplcen.apl.jhu.edu> trweil@aplcen.apl.jhu.edu (Weil Timothy Robert) writes: >I'd like to be prompted after login as to which directory >I'd like to be working in - > >Tried a simple prompting via shell script; also tried >inserting same prompting in .profile (Ultrix running >Korn Shell)... > >results were similar - a 'pwd' would indicate that I'd >changed to the selected directory but UNIX kept me >logged into $HOME....any other tricks to try? > I don't know about korn shell, but Bourne shell works with: c=`echo "\c"`; [ "$c" = "" ] && { c="\c"; n=""; } || { c=""; n="-n"; } echo $n "Enter working directory: $c" read HOME export HOME cd $HOME if you put it into the .profile. any cd after this will take you to $HOME (i.e. your newly specified working directory) don't worry about the first line, it just works out if you need \c or -n to stop echo sending a newline to the terminal Mike -- -------------------------------------------------------------------------- Usual disclaimer..... etc | mike@x.co.uk True Intelligence is not knowing all the answers, | it's knowing the right questions. |
gwyn@smoke.BRL.MIL (Doug Gwyn) (06/18/90)
In article <111@npdiss1.StPaul.NCR.COM> mercer@npdiss1.StPaul.NCR.COM (Dan Mercer) writes: >There are two ways of executing a Bourne shell script There is a third way, which is the one that is relevant here -- the shell automatically sources the script. This is always done for ~/.profile in a login shell and may also be done for some enhanced shells on a per-interactive-shell basis. These scripts are supposed to be executed in the current context of the shell, so their effects are supposed to stick.