Free Downloads, Community Forum,
FAQs and Developer Resources


Make /Tools Your Home | Link to us

Today's posts | Posts since last visit | Most Active Topics

All Forums Register Login Search Subscriptions My Profile Inbox
Tool Warehouse FAQs Resources Help Member List Address Book Logout

$HOME questions

 
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [SFU / Interix / SUA Technology] >> SFU / Interix - Getting Started >> $HOME questions Page: [1]
Login
Message << Older Topic   Newer Topic >>
$HOME questions - Jan. 29, '04, 7:34:40 PM   
Keehan_Mallon

 

Posts: 32
Joined: Jan. 23, '04,
Status: offline
I have set home in the Windows GUI to C:\SFU\home\username for all my users. Now, I have $PWD referenced into the PS1 var for ksh. The prompt displays the full POSIX path /dev/fs/C/SFU/home/username instead of what I was expecting /home/username.

Is this possible?

It seems like regardless of where $HOME is defined to be in the Windows GUI, SFU should be able to link it to /home/username. This could be done automatically at install and would simplify things quite a bit.

Keehan
Post #: 1
RE: $HOME questions - Jan. 29, '04, 9:52:23 PM   
markfunk

 

Posts: 673
Joined: Mar. 31, '03,
Status: offline
Instead of PS1=${PWD} you could use PS1=" ${PWD#/dev/fs/C/SFU}"

or more generically:
PS1=" /$(PWD#$INTERIX_ROOT}"

Or if you prefer, you could modify HOME in /etc/profile as:
export HOME=" ${HOME#$INTERIX_ROOT}"
to remove the installation directory prefix if it exists in HOME.

(in reply to Keehan_Mallon)
Post #: 2
RE: $HOME questions - Feb. 3, '04, 3:18:16 PM   
Keehan_Mallon

 

Posts: 32
Joined: Jan. 23, '04,
Status: offline
Mark,

I have been able to get the results that I want out of the $HOME variable by setting (in /etc/profile.lcl) HOME=" ${HOME#$INTERIX_ROOT}" as you suggested. Also, in profile.lcl I do a cd $HOME. The reason for this is that I have setup a symlink from /dev/fs/C/SFU/home to /home, so this has the side effect of having pwd report the correct path of /home/username. That all works fine.

The only problem that I am having now is the PS1 variable. I have set PS1 to: PS1=" machinename:$PWD$ " in profile.lcl. The problem I am having is that PS1 is not updating when I change directories? Have you ever seen this problem before? Any ideas?

Keehan

(in reply to Keehan_Mallon)
Post #: 3
RE: $HOME questions - Feb. 3, '04, 4:45:55 PM   
markfunk

 

Posts: 673
Joined: Mar. 31, '03,
Status: offline
You need to force the evaluation of $PWD to be delayed. Try

PS1=" \$PWD$ "

(in reply to Keehan_Mallon)
Post #: 4
RE: $HOME questions - Feb. 3, '04, 5:47:26 PM   
Keehan_Mallon

 

Posts: 32
Joined: Jan. 23, '04,
Status: offline
That works. Very interesting.

(in reply to Keehan_Mallon)
Post #: 5
RE: $HOME questions - Feb. 3, '04, 11:41:34 PM   
EugeneTSWong

 

Posts: 9
Joined: Jan. 27, '04,
Status: offline
Wow Mark! That' s good magic.

Would you please be willing to teach us why that little bit makes all the difference? Is this common to most Unix environments?

(in reply to markfunk)
Post #: 6
RE: $HOME questions - Feb. 4, '04, 9:27:49 AM   
markfunk

 

Posts: 673
Joined: Mar. 31, '03,
Status: offline
This is basic shell behaviour. Any good book on ksh or shell programming should be able to explain this.

If you don' t like using the \ char, then another solution is:
PS1=' $PWD$ '

(in reply to Keehan_Mallon)
Post #: 7
RE: $HOME questions - Feb. 4, '04, 3:32:05 PM   
EugeneTSWong

 

Posts: 9
Joined: Jan. 27, '04,
Status: offline
Thanks Mark.

I remember reading the Advanced BASH Scripting Guide, but I guess I read through much too quickly.

To help out those who are just starting, here is the chunk of code that sets up my prompt & path.

if [ `/bin/whoami` = ' Administrator'  ]
then
        # Do not set PS1 for dumb terminals
        if [ " $TERM"  != ' dumb'   ] && [ -n " $BASH"  ]
        then
                PS1=" Server24 \${PWD#/dev/fs/C/SFU} # " 
#               eval PS1=' \[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]' 
        fi
                PATH=" /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:${ROOTPATH}:${PATH}" 
else
        # Do not set PS1 for dumb terminals
        if [ " $TERM"  != ' dumb'   ] && [ -n " $BASH"  ]
        then
                PS1=" `whoami`@Server24 \${PWD#/dev/fs/C/SFU} \$ " 
#               eval PS1=' \[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]' 
                PATH=" /bin:/usr/bin:${PATH}" 
        fi
fi


The admin' s prompt looks like:
Server24 /home/Administrator #
and the regular user' s prompt looks like:
eugene@Server24 /home/eugene $

< Message edited by EugeneTSWong -- Feb 4, '04, 3:22:17 PM >

(in reply to markfunk)
Post #: 8
More $HOME questions - Feb. 5, '04, 6:12:35 PM   
EugeneTSWong

 

Posts: 9
Joined: Jan. 27, '04,
Status: offline
Hi again.

I noticed that when I ssh into the server, I get the prompt that I like. However, when I click on the bash menu item, I don' t get the prompt that I like. I tried typing, " . /etc/profile.lcl" , & I get no errors, but I also don' t get the prompt that I like. Does anybody have understand why this is?

(in reply to Keehan_Mallon)
Post #: 9
RE: $HOME questions - Feb. 5, '04, 8:21:52 PM   
markfunk

 

Posts: 673
Joined: Mar. 31, '03,
Status: offline
what' s a " bash menu item" .
I don' t understand what you' re doing. Sorry.

(in reply to Keehan_Mallon)
Post #: 10
RE: $HOME questions - Feb. 6, '04, 7:19:17 PM   
EugeneTSWong

 

Posts: 9
Joined: Jan. 27, '04,
Status: offline
Oops. I thought that it might be safe to assume that I was clear, but I guess that I was a step ahead. If you go to Start Menu --> Programs --> Windows Services For Unix, then you would find menu items like C Shell & Korn Shell. I created a menu item for bash. When I click it, it' s supposed to execute:
C:\WINNT\system32\posix.exe /u /c /usr/local/bin/bash -l

I basically copied it & modified it from the C Shell menu item.

Is the bash menu item doing something incorrectly?

(in reply to markfunk)
Post #: 11
RE: $HOME questions - Feb. 6, '04, 7:34:47 PM   
markfunk

 

Posts: 673
Joined: Mar. 31, '03,
Status: offline
That looks ok.
The -l option tells bash that its to act like a login shell. As such, it should read and execute the /etc/profile file.
For problems like this, I either invoke the shell with -x and -l (... bash -l -x) which traces the commands as it goes thru /etc/profile (...).

But it doesn' t say which files its doing.
So instead of bash -x, I will edit the files themselves
and put " set -x" in them or just some " echo " DEBUG: in /etc/profile" debugging statements.

(in reply to Keehan_Mallon)
Post #: 12
RE: $HOME questions - Feb. 7, '04, 12:05:43 AM   
EugeneTSWong

 

Posts: 9
Joined: Jan. 27, '04,
Status: offline
I figured out the problem. I didn' t set $TERM to interix. So I modified the code above to look something like the following code. I honestly consider it crude & not very well done. If anybody has a better way of setting $TERM to interix when it is interix, then I' d be glad to know.

if [ " $TERM"  != ' dumb'   ] && [ -n " $BASH"  ]
then
        if [ `/bin/whoami` = ' Administrator'  ]
        then
                export PS1=" Server24 \${PWD#/dev/fs/C/SFU} # " 
#               eval PS1=' \[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]' 
                export PATH=" /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:${ROO
TPATH}:${PATH}" 
        else
                PS1=" `whoami`@Server24 \${PWD#/dev/fs/C/SFU} \$ " 
#               eval PS1=' \[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]
' 
                PATH=" /bin:/usr/bin:${PATH}" 
        fi
else
        # When entering here, this means that the terminal should be
        # considered dumb
        TERM=" interix" 
        if [ `/bin/whoami` = ' Administrator'  ]
        then
                PS1=" Server24 \${PWD#/dev/fs/C/SFU} # " 
#               eval PS1=' \[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]' 
                PATH=" /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:${ROOTPATH}:
${PATH}" 
        else
                PS1=" `whoami`@Server24 \${PWD#/dev/fs/C/SFU} \$ " 
#               eval PS1=' \[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]
' 
                PATH=" /bin:/usr/bin:${PATH}" 
        fi
fi


< Message edited by EugeneTSWong -- Feb 6, '04, 9:26:55 PM >


_____________________________

Sincerely, & with thanks,
Eugene T.S. Wong

(in reply to markfunk)
Post #: 13
Page:   [1]
All Forums >> [SFU / Interix / SUA Technology] >> SFU / Interix - Getting Started >> $HOME questions Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Search All Forums -

Advanced search


SPONSORS



Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI

0.047