Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Prevent undefined variable error on remote login UNIX
In the hint on fixing tcsh, there's a short exchange in the comments regarding an undefined error message after fixing the tcsh shell. "Robert" writes:
I followed the instructions, but now I get a message "TERM_PROGRAM: Undefined variable." when I log in by SSH. This did not happen in 10.1.
"vajonez" wrote in with the answer (also separately submitted by "TheGS"):
There is a typo in /usr -> share -> tcsh -> examples -> aliases. Change the line that says:
if ("$TERM_PROGRAM" == "Apple_Terminal") then
if ("$?TERM_PROGRAM" == "Apple_Terminal") then
You'll need to "sudo" edit this file, as it's owned by root. I can attest that fixing the typo removes the error message.
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)

Prevent undefined variable error on remote login | 3 comments | Create New Account
Click here to return to the 'Prevent undefined variable error on remote login' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
shell commands to make the fix
Authored by: Seth Milliken on Aug 28, '02 12:22:51PM
sed 's/$TERM_PROGRAM/$?TERM_PROGRAM/' /usr/share/tcsh/examples/aliases > /tmp/aliases
sudo mv /tmp/aliases /usr/share/tcsh/examples/aliases

[ Reply to This | # ]
The apple way
Authored by: to0l25 on Aug 28, '02 12:58:02PM
my problem was, that i didn't get the bbedit shell worksheets to work (same error: "TERM_PROGRAM: Undefined variable"). i had to search for a while, cause i didn't want to modify those files as root in the heart my of system. but i found an apple way to handle with those issues (=> setting up environment). just create a folder called ".MacOSX" in your home-directory. now create a file and name it "environment.plist". you need to add the following lines into this file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> <plist version="1.0"> <dict> <key>TERM_PROGRAM</key> <string>Apple_Terminal</string> </dict> </plist> you need to login and logout, so that your system recognizes the enviroment variables. the advance is, that with this way, _every_ carbon and cocoa app is able to use these variables. since i know that, life gots much easier :-) reference: take care, christian

[ Reply to This | # ]
Authored by: kholburn on Oct 03, '02 07:35:51AM

if ("$TERM_PROGRAM" == "Apple_Terminal") then
if ("$?TERM_PROGRAM" == "Apple_Terminal") then
will not give an error but it changes the meaning. $?TERM_PROGRAM is a number 0 or 1 depending on whether the variable $TERM_PROGRAM exists or not. It can never equal "Apple_Terminal" so you may as well comment the if statement out:
# if ("$TERM_PROGRAM" == "Apple_Terminal") then
# alias settermtitle 'echo -n "^[]2;\!:1^G"'
# endif

Or you can correct the script by enclosing the if statement in another :
if ( $?TERM_PROGRAM ) then
if ("$TERM_PROGRAM" == "Apple_Terminal") then
alias settermtitle 'echo -n "^[]2;\!:1^G"'

You have to enclose it because tcsh doesn't shortcut boolean expressions in "if" statements - if you put :
if ( $?TERM_PROGRAM && "$TERM_PROGRAM" == "Apple_Terminal")
tcsh would try to evaluate both parts (which bash or sh would not do) and would fail when the $TERM_PROGRAM variable doesn't exist.

Actually this line causes my terminal windows to have their title renamed to \!: which I don't like much so I think commenting out is better.

[ Reply to This | # ]