|
|
#1 |
|
All Star
Join Date: Jan 2002
Location: NY, NY
Posts: 776
|
Modifying tcsh path the proper way.
I'm trying to modify my path in a secure way as instructed in the readme at:
/usr/share/init/tcsh/README. Code:
[localhost:share/init/tcsh] hs2admin% more readme
This directory contains some useful tcsh files.
In order to use this configuration:
echo "source /usr/share/init/tcsh/rc" > ~/.tcshrc
echo "source /usr/share/init/tcsh/login" > ~/.login
echo "source /usr/share/init/tcsh/logout" > ~/.logout
To do this system-wide, do the same instead to /etc/csh.cshrc,
/etc/csh.login, and /etc/csh.logout.
In order to customize tcsh:
mkdir ~/Library/init/tcsh
and create the following files there as necessary:
aliases.mine - shell aliases
completions.mine - completions
environment.mine - environment
rc.mine - run commands
path - command search path
See the corresponding file in /usr/share/init/tcsh for more information about
the role of each file. You can easily extend or override the configuration
provided by the default file. For example, you can add more aliases by adding
the appropriate commands in aliases.mine.
-Fred
Massachusetts Institute of Technology
tritan@mit.edu
Code:
Welcome to Darwin!
/Developer/Tools/: Permission denied.
/Developer/Tools/: Permission denied.
[localhost:~] hs2admin% CpMac
CpMac: Command not found.
[localhost:~] hs2admin% /Developer/Tools/CpMac
usage: /Developer/Tools/CpMac [-r] [-p] [-mac] <source-path> <dest-path>
/Developer/Tools/CpMac [-r] [-p] [-mac] <source-path>... <dest-dir>
[localhost:~] hs2admin%
Please note: I'm trying to avoid directly modifying the /usr/share/init/tcsh/login file as per the issues discussed in this thread (ie adding files writable by other than root to roots path.) I'm also looking for more than just: set path = ($path /Developer/Tools) as this seems to only affect the current terminal session. Thanks, Hugh |
|
|
|
|
|
#2 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
hey hugh,
you show me your perms and i'll show you mine [;= % ll -d /Developer/ drwxrwxr-x 13 root admin 398 Jan 3 15:23 /Developer// % ll -d /Developer/Tools/ drwxrwxr-x 20 root admin 636 Jan 3 15:30 /Developer/Tools// what group is your username in? % id uid=501(merv) gid=20(staff) groups=20(staff), 0(wheel), 80(admin) i don't exactly like the group write in /Devo, but i'm not going to change it yet. now then, you _should_ avoid directly modifying the /usr/share/init/tcsh/login -- also looking for more than just: set path = ($path /Developer/Tools) as this seems to only affect the current terminal session. -- No, the development environment should only be set up per terminal session. What if you wanted to test a product as user Sally Punchclock? You would want sally's environment not to have any access to /developer and you would sudo/su sally and test your product under the guise of simple user. we call this 'sandboxing' Grok? We could start a treatise on a Devo->QA->Production environment if it's interesting to anybody. Last edited by mervTormel; 02-05-2002 at 11:57 AM. |
|
|
|
|
|
#3 | |||||||||||||||||||
|
All Star
Join Date: Jan 2002
Location: NY, NY
Posts: 776
|
Merv - you're in the majors now!!! How did I know you would come to the rescue again? LOL
Code:
Welcome to Darwin! [localhost:~] hs2admin% ll -d /Developer drwxrwxr-x 11 root admin 330 Nov 10 01:20 /Developer [localhost:~] hs2admin% ll -d /Developer/Tools drwxrwxr-x 20 root admin 636 Jan 28 09:01 /Developer/Tools [localhost:~] hs2admin% id uid=501(hs2admin) gid=20(staff) groups=20(staff), 0(wheel), 80(admin) [localhost:~] hs2admin%
Perhaps I'm wrong - but won't adding the path to my ~/Library/init/tcsh/path only affect my path? Can't I su to or login as another user and not let them have access? Thanks, Hugh |
|||||||||||||||||||
|
|
|
|
|
#4 |
|
MVP
Join Date: Dec 2001
Location: Portland, OR
Posts: 1,472
|
Here's the line I used in the "path" file to add the Developer Tools, and it seems to have worked:
Code:
% cat path
setenv PATH ${PATH}:/Developer/Tools:/Developer/Applications
-rob. |
|
|
|
|
|
#5 |
|
All Star
Join Date: Jan 2002
Location: NY, NY
Posts: 776
|
Hey Rob,
Perhaps I'm doing something wrong - but that command only adds to the path through the current terminal session. It expires (on my machine) when I launch a new terminal. The file I added to my path was as follows: Code:
/Developer/Tools Thanks, Hugh |
|
|
|
|
|
#6 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
thanks, rob. that is rather obvious, but if you use tcsh, your env PATH may be out of sync with your shell variable path.
tcsh auto exports the value of shell variable path to env PATH, so i think you might want to be setting path in your ../tcsh/path # What is a cooler way to set my path with tcsh? # If you want to make sure only directories that exist are in your path, you can use something like this: Code:
echo ""
echo -n "wrangling path... "
set d=($path)
set p=()
foreach x ( $d )
if (-d $x ) set p=( $p $x )
end
set path = ( $p )
unset p d
echo $path
echo " $PATH"
set path = ( $path /tmp ) With a Bourne shell syntax you can use: PATH="$PATH:/tmp" ; export PATH -- now back to our regularly scheduled program... hugh, i need to re-read the posts and investigate. i'll comment some more later. |
|
|
|
|
|
#7 |
|
MVP
Join Date: Dec 2001
Location: Portland, OR
Posts: 1,472
|
The above line is the sole contents of my "path" file in ~/Library/init/tcsh, so it loads each time I open a new Terminal window. I just used "cat" to show the output.
I guess I'm confused; I thought I was doing it the way OS X wanted - by using a "path" file in ~/Library/init/tcsh. Merv, why won't this work?? -rob. |
|
|
|
|
|
#8 |
|
All Star
Join Date: Jan 2002
Location: NY, NY
Posts: 776
|
Rob,
I misunderstood the proper syntax of the path file. By using your command as the ~/Library/init/tcsh/path file the problem was solved. Thank you, Hugh Edit - this of course brings up a question. Why does the first way show up but give a permissions error? Last edited by hschickel; 02-05-2002 at 01:20 PM. |
|
|
|
|
|
#9 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
rob,
urp, sorry for the confusion, loss of focus, the env variable 'PATH' and the shell variable 'path' are kept in sync automagically, in tcsh. you are doing it right, obviously, and it does work. i thougt it was a one way sync 'path'->'PATH' hugh, what i suspect is that ~/.tcshrc or .login may be possibly stepping on your path? or thwarting your call to ~/lib.../tcsh/path ? i had a lot of trouble with consistent new shell windows when i had those files in my $HOME. so i rm'd them. now, i use the ~/lib.../tcsh/*.mine files exclusively. it simplified my startup. check that out by investigating those $HOME tcsh startup files, possibly renaming them (to save them) and see if a new terminal window has the path of your first shell window. |
|
|
|
|
|
#10 |
|
All Star
Join Date: Jan 2002
Location: NY, NY
Posts: 776
|
Merv,
I looked a little more closely at the ~/.login, ~/.logout and ~/.tcshrc files. I believe the are precluded by the system wide /etc/csh.cshrc, /etc/csh.login and /etc/csh.logout files. In any case, I rm'd 'em. The real key is in the ~/Library/init/tcsh directory. My issue with ~/Library/init/tcsh/path was syntax. I used /Developer/Tools when I should have used set path = ($path /Developer/Tools) or setenv PATH ${PATH}:/Developer/Tools. I'm not sure what the difference is exactly so I used the first (it was simpler). With my track record here that is probably a huge security hole though. ![]() Thanks, Hugh |
|
|
|
|
|
#11 |
|
Prospect
Join Date: Mar 2002
Location: Los Angeles, CA
Posts: 8
|
I've reviewed the posts here, as well as the READ ME file for customizing my environment.
The only one I really want to customize is the path and classpath variables. So I entered the following into ~/Library/init/tcsh/path: ## # ~/Library/init/tcsh/path ## # Michael Frankel # Wizard Consulting Group # 27 MAR 2002 ## # Add PATH for Apple Developer Tools # set path = ($path /Developer/Tools) # # Add CLASSPATH for JDBC software # set classpath = ($classpath /Users/michaelf/Library/Java/mm.mysql.jdbc-1.2c) # ## # End of ~/Library/init/tsch/path ## However, when I open up Terminal, this is what I see: Missing }. Missing }. }: Command not found. Missing }. red255green255blue255: Command not found. }: Command not found. margl1440margr1440vieww13920viewh8640viewkind0: Command not found. pardtx560tx1120tx1680tx2240tx2800tx3360tx3920tx4480tx5040tx5600tx6160tx6720qlqnatural: Command not found. I have NO idea what this means. Any ideas? Thanks...
__________________
Michael Frankel Director of Technology The Database Factory www.thedatabasefactory.com |
|
|
|
|
|
#12 | ||||||||||||||||||||||||||||||||||||||
|
Triple-A Player
Join Date: Apr 2002
Location: Restaurant at the End of the Universe
Posts: 171
|
Case Sensitive
should be CAPS set PATH = ($PATH /Developer/Tools)
CAPS set CLASSPATH = ($CLASSPATH /Users/.../Java I think you stop at the directory where your packages start. not sure though. -bakaDeshi
__________________
—bakaDeshi Caution! Mac User at the Command Line. |
||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
#13 | |||||||||||||||||||
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
Re: Case Sensitive
no, the lowercase form is proper for the tcsh set shell variable command. the tcsh setenv command would use uppercase PATH to set the environment variable. tcsh maintains equivalent values with the shell variable $path and the environment variable $PATH $path is a whitespace delimited list of dirs $PATH is a colon delimited list of dirs Code:
% echo $path /Users/merv/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin % echo $PATH /Users/merv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin |
|||||||||||||||||||
|
|
|
|
|
#14 |
|
Triple-A Player
Join Date: Apr 2002
Location: Restaurant at the End of the Universe
Posts: 171
|
Sure is. thanks for the correction.
![]() Unix is case sensitive. Apparently, not everywhere. Does this only apply to environment variables in setting your defaults or are there other places where I can use lowercase? Some consistency would be nice, although I like typing "echo $path" in lowercase without switching to uppercase. Learned something new today.
__________________
—bakaDeshi Caution! Mac User at the Command Line. |
|
|
|
|
|
#15 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
unix is case sensitive. everywhere. you can use any case you want. eVeN StRaNgE CaSe. by convention, environment variables are uppercase; they are not required to be. the best approach is to be consistent with your notation, and to play by the rules that convention dictates.
iForOneUseHungarianNotation. itsEasyOnTheEyes andUsesTheMinimumCharactersAndCaseTwiddlings tcsh just happens to have a shell variable called path that is space delimited and changes to its value are reflected in its environment variable PATH. and visa versa. i don't know why. it's bizarre. except in the code: Code:
% set PATH = ($PATH /Developer/Tools) % echo $PATH /Users/merv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin /Developer/Tools % echo $path /Users/merv/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin |
|
|
|
![]() |
|
|