The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   tcsh funkiness (http://hintsforums.macworld.com/showthread.php?t=470)

lancelot183 01-28-2002 08:46 PM

tcsh funkiness
 
what happened here?

Welcome to Darwin!
tcsh_initdir: Undefined variable.
>

anybody know? thanks!! it's not a huge deal, because i'm using bash, but i'm curious... :D

mervTormel 01-28-2002 08:58 PM

i suspect that bash is running through your startup scripts and one of these contains references to, or directly calls, the tcsh init scripts in your home dir.

check ~/.profile and for your bash startup scripts calling a tcsh startup script.

read the bash man pages about verbose mode

open a new terminal window and

$ exec bash -v

perhaps that will uncover the problem script.

let us know.

lancelot183 01-28-2002 09:07 PM

um... no, sorry.
 
nice thought... but no cigar.

sorry, i didn't mention that the reason i installed bash was because of this strange "tcsh_initdir undefined" thing.

verbose execution of bash yields nothing.
also, i don't seem to have a .profile... is that bad?

thanks!

mervTormel 01-28-2002 09:25 PM

i suspect that you may have installed bash, but are still running a fractured tcsh installation in the terminal app.

show us some more info

show us the result of these commands:

> echo $version

> echo $SHELL

lancelot183 01-28-2002 09:35 PM

i've got both installed...
 
bash2.05 lancelot@localhost ~ % echo $version

bash2.05 lancelot@localhost ~ % echo $SHELL
/bin/tcsh

there 'tis.

one more thing: i know i've got both installed. but... i want to be able to switch between them without a big deal.

when i tell Terminal to use tcsh, i get the tcsh_initdir undefined thing.
bash works fine.

make any sense?

mervTormel 01-28-2002 09:45 PM

o i c

i thought you were running bash and getting the tcsh_initdir error. sheesh.

you have a fractured tcsh installation.

read and follow the instructions in the readme from the tcsh init bucket

% ll /usr/share/init/tcsh/
total 40k
-rw-r--r-- 1 root wheel 952 Sep 2 20:35 README
-rw-r--r-- 1 root wheel 892 Sep 2 20:35 aliases
-rw-r--r-- 1 root wheel 9.4k Sep 2 20:35 completions
-rw-r--r-- 1 root wheel 433 Sep 2 20:35 environment
-rw-r--r-- 1 root wheel 701 Sep 2 20:35 login
-rw-r--r-- 1 root wheel 395 Sep 2 20:35 logout
-rw-r--r-- 1 root wheel 1.9k Sep 2 20:35 rc
-rw-r--r-- 1 root wheel 2.3k Sep 2 20:35 tcsh.defaults

lancelot183 01-28-2002 10:38 PM

am i that confusing? ;)
 
<sigh> that came really close, but no dice...

i read the README and configured tcsh back... i now have

aliases.mine
completions.mine
environment.mine
rc.mine
path

in ~/Library/init/tcsh

also, it sucessfully made ~/.tcshrc, ~/.login, and ~/logout. yet... it still does this when i try to run tcsh as the main shell in Terminal:

tcsh_initdir: Undefined variable.
>

heh.. on a sidenote, i just noticed that if you don't select "Use Default Shell" in the Terminal prefs, it doesn't say "Welcome to Darwin!" hm. anyhoo...

any clearer? or still mud?

thanks for your time!

mervTormel 01-28-2002 11:03 PM

okay, let's look at this then...

Code:

% ll /etc/csh*
-rw-r--r--    1 root    wheel          31 Sep  2 20:35 /etc/csh.cshrc
-rw-r--r--    1 root    wheel          34 Sep  2 20:35 /etc/csh.login
-rw-r--r--    1 root    wheel          35 Sep  2 20:35 /etc/csh.logout

% cat /etc/csh.cshrc
source /usr/share/init/tcsh/rc

% less /usr/share/init/tcsh/rc
##
# TCSH Expanded C-Shell INITIALIZATION FILE
#
<snip>

set default_tcsh_initdir = /usr/share/init/tcsh
set user_tcsh_initdir    = ~/Library/init/tcsh

if (-r "${user_tcsh_initdir}") then
  set tcsh_initdir = "${user_tcsh_initdir}"
else
  set tcsh_initdir = "${default_tcsh_initdir}"
endif
...

if your tcsh startup doesn't look like this, that could be it.

if it does look like this, then we need to find where the ref to tcsh_initdir poops out.

try

% exec tcsh -V

and follow this up to where the undefined error is and let us know.

BTW, the last part of this could get very long because it processes your command history file, so page up to the beginning of -V run and follow from there.

lancelot183 01-28-2002 11:36 PM

quick question
 
is it bad if i don't have a csh.cshrc? :(

mervTormel 01-28-2002 11:44 PM

urp!

yep. well, er, no, not bad qua bad, but it's problematic if you want tcsh to work well.

here are the ownership, permissions, and contents of csh.cshrc

Code:

% ll /etc/csh.cshrc
-rw-r--r--    1 root    wheel          31 Sep  2 20:35 /etc/csh.cshrc

% cat /etc/csh.cshrc
source /usr/share/init/tcsh/rc

you should prolly have csh.login and csh.logout, too.

that should get you started at solving this problem. let us know how you do.

lancelot183 01-29-2002 12:00 AM

difficulty
 
ok, i made the file... but i used the GUI to c&p the contents of rc into it... and now it's 1960 bytes... whereas yours says 31...

'scuse my newbiness: what's cat and source do? i tried doin what you showed in our code, but it didn't quite work. is that line break s'posed to be there?

btw, the top of my rc file looks the same as yours.

i think we're gettin close...

lancelot183 01-29-2002 12:43 AM

mm'k...
 
alright, now that i have a csh.cshrc file... and it looks exactly like the tcsh/rc file... when i try to run tcsh i get this:

[Process was terminated by signal 11]

any ideas?

mervTormel 01-29-2002 12:45 AM

Re: difficulty
 
something's wrong with 1960 bytes.

read thru all of this first and try these things:

Code:

% unset noclobber
% sudo echo "source /usr/share/init/tcsh/rc" > /etc/csh.cshrc
% sudo chmod u=rw,go=r /etc/csh.cshrc
% sudo chown root:wheel /etc/csh.cshrc

sudo is gonna ask for your password. i don't know how you got your GUI editor to save /etc/csh.cshrc

what GUI editor did you use?

cat = concatenate files and print to standard output, that is, display file contents

source = tcsh's builtin command to tell the shell to read and execute commands in a file

you can read documentation about commands in the infamous man pages

% man cat
% man tcsh

i don't know which line break you're referring to, alas.

sudo - execute command as other user
echo - write args to stdout
chmod - change access modes (permissions)
chown - change owner:group

okay, now dig into those man pages

mervTormel 01-29-2002 12:49 AM

Re: mm'k...
 
Quote:

Originally posted by lancelot183
alright, now that i have a csh.cshrc file... and it looks exactly like the tcsh/rc file... when i try to run tcsh i get this:

[Process was terminated by signal 11]

any ideas?

% exec tcsh -V

will spit back every line the shell executes. the last one may have caused your sigterm 11.

some shell startup code is protected and it must run without error or die hard. what you got is the die hard scenario.


at this point, you need to get that /etc/csh.cshrc proper, then we can approach the remaining issues

lancelot183 01-29-2002 01:07 AM

what in the world?
 
bash2.05 lancelot@localhost ~ % unset noclobber
bash2.05 lancelot@localhost ~ % sudo echo "source /usr/share/init/tcsh/rc" > /etc/csh.cshrc
bash: /etc/csh.cshrc: Permission denied

this is most odd.

thanks for the explanations of the commands... i asked before i thought to do a "whatis" on 'em, or a man lookup. :D
i'm slowly but surely gettin the hang of this UNIX shtuff... thanks very much for your patience.

do you use AOLIM? that might be faster... if you want to. my s/n is scapegoat51 (it's in my profile, of course, but i figure those extra clicks can be put to better use elsewhere )

lancelot183 01-29-2002 01:36 AM

hmm..
 
does this look like an endless loop to you? goto:
http://www.bonnvie.com/~lroggy/shtuff/tcshoutput.txt

that's what i got when i did exec tcsh -V.

not sure what that tells us, but...

mervTormel 01-29-2002 01:38 AM

re: AOLIM, um, no

sorry, i can't seem to perform that sudo echo either. i don't understand that. and i want to emphasize this important point: test your code, and don't trust any given to you until you consider what it does.

so, use pico to edit that /etc/csh.cshrc

% sudo pico /etc/csh.cshrc

control-k (kill) all lines in that file and paste in this:

source /usr/share/init/tcsh/rc

control-x to quit, answer yes to the save prompt

then be sure to chmod, chown that puppy (sudo'd of course)

then open a new terminal (command-n) window and % exec tcsh

boy, that sure is wonky. i regret that this has been wonky for you. i'll try and find why that echo redirect (>) is so wonky.

your humble wonker,

-mt

mervTormel 01-29-2002 01:43 AM

Re: hmm..
 
Quote:

Originally posted by lancelot183
does this look like an endless loop to you? goto:
http://www.bonnvie.com/~lroggy/shtuff/tcshoutput.txt

that's what i got when i did exec tcsh -V.

not sure what that tells us, but...

yep. loopy. yer tcsh install is hosed.

BUT, this is a good excersise for sleuthing and using some common commands.

let's keep digging. get that csh.cshrc script correct, then we can proceed.

it should look like this when you're done

Code:


% ll /etc/csh.cshrc
-rw-r--r--    1 root    wheel          31 Sep  2 20:35 /etc/csh.cshrc

% cat /etc/csh.cshrc
source /usr/share/init/tcsh/rc


lancelot183 01-29-2002 01:49 AM

ah, the smell of miscommunication in the morning...
 
ok, i understand things better now.

first, i thought csh.cshrc was supposed to be an exact duplicate of tcsh/etc. little did i know... so, that's fixed. now my csh.cshrc file is right.
however... it's still dropping out with a sigterm 11. (whatever that means...)

also, to answer your earlier question about GUI text editors:
i use BBEdit 6.1 Lite. and all i did was use "open [pathto rc]" to open that folder in the Finder, and then opened rc in BBEdit, then c&p'd it to pico. which, as i know see, was not what you were tryin to get me to do. :D

trial and error...

mervTormel 01-29-2002 01:53 AM

for some reason, the permissions of the target needed to be group:write to echo to a root:wheel owned file. i don't understand that.

Code:

% sudo chmod g=r foo

% ll foo
-rw-r-----    1 root    wheel          4 Jan 28 22:47 foo

% sudo echo "foo" > foo
foo: Permission denied.

% sudo chmod g=rw foo

% ll foo
-rw-rw----    1 root    wheel          4 Jan 28 22:50 foo

% sudo echo "foo" > foo

% cat foo
foo

wonky cat food.


All times are GMT -5. The time now is 10:35 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.