|
|
#1 |
|
Prospect
Join Date: Apr 2003
Posts: 9
|
Newbie with some questions
Hello all,
I'm new to the mac / unix world. I recently just purchased a powerbook 12 inch and installed the developer tools. I have a few questions: When i am in the unix terminal, I've logged into unix as the root user and i get the message: tcsh: cannot open /etc/termcap tcsh: using dumb terminal settings. also, i'm using gcc and i can compile and make just fine, but when i'm running my program i get a: terminal database is inaccessible. The code works because i've tested it in linux. What i'm doing is writing and reading from files (.txt and .dat.) One of the kids in school said in might be a permissions problem. I would apreciate any and all advice on this matter. Eldwin |
|
|
|
|
|
#2 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
details needed
How about some more details of what you are doing?
Are you by any chance using a xterm under X Windows? (If so, this query is more suited for the X Windows section of the forums.) Does your program make use of a curses-based user interface? If you are 'root', then it is very unlikely that you are having permission problems. The more basic problem is that something in the software you are using (your own program or the terminal it is running in) is looking for the file /etc/termcap. This file does not exist on a standard OS X system. Last edited by hayne; 04-30-2003 at 02:04 AM. |
|
|
|
|
|
#3 |
|
Prospect
Join Date: Apr 2003
Posts: 9
|
I'm not sure what you mean by xterm and X window.
I'm in a software engineering class and we've put together a text based role playing game. During execution of the program, you are required to create or choose a previously created player. (Both will require to read info from a .txt file and .dat file.) The program does write to file properly, but it bails out when trying to read from file. Like i said, it works on Linux as far as reading, writing, playing the game. I'm just unfamiliar with these error messages. Thanks for your help Eldwin |
|
|
|
|
|
#4 | |||||||||||||||||||
|
Moderator
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
|
Can you give us more info on how you do it? |
|||||||||||||||||||
|
|
|
|
|
#5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
Terminal
So then, can I assume that you are using the "Terminal" application that is suppled by Apple under the Application/Utilities folder?
Tell us what the interaction with the game is like. Did you write this part of the game or were you supplied with some of the software?
Unfortunately, the code working on Linux merely means that it should be relatively easy to port to OS X - there is no guarantee of it automatically working without you making changes to the code to make it OS X compatible. That is why I asked above about the user-interface of the game. A program with straight text-input from a prompt and straight text-output will work without changes on any UNIX system. But if you do anything fancy in the user-interface, like positioning text at a certain place on the screen (as opposed to just letting it scroll up in the Terminal) then you have to be careful to avoid system dependencies. It sounds like some part of your program has such system dependencies, otherwise it wouldn't be looking for the file /etc/termcap. This may be a library that you are linking against - not necessarily just the code that you wrote. Here's a test program, just to check that your basic input & output is working. Try compiling and running this program and let us know what happens with it. (Not sure if you are using C or C++, so I stuck to plain C.) Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Hello Eldwin\n");
printf("Enter an integer:\n");
int num;
if (scanf("%d", &num) != 1)
{
fprintf(stderr, "Bad input\n");
exit(1);
}
FILE *fp = fopen("junk.txt", "w");
if (fp == 0)
{
fprintf(stderr, "Can't open file for writing\n");
exit(1);
}
fprintf(fp, "%d\n", num);
fclose(fp);
printf("Your number was written to the file \"junk.txt\"\n");
return 0;
}
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
#6 |
|
Prospect
Join Date: Apr 2003
Posts: 9
|
I've narrowed down the problem to reading and writing from/to binary .dat files.
In an attempt to prevent hacking of the game, we stored all the info of players/monsters/equipment in binary.dat files. Obviously when someone opens one of these files up in a notepad, its going to look like a bunch of garbage. As far as input, its just taking straight text input and displaying straight text output. |
|
|
|
|
|
#7 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
answers?
You still haven't answered some of the questions I asked.
- are you using the Terminal program from Utilities? - are you linking with any libraries? What exactly are the problems you are having with these binary files? What does the reading & writing of binary files have to do with termcap - or are we now talking about a different problem? |
|
|
|
|
|
#8 |
|
Prospect
Join Date: Apr 2003
Posts: 9
|
Ok when I start Darwin (yes it is a terminal from utilities), I type in 'login' and enter my user name and password.
After I do so, I get the file/etc/termcap line. The folder, where the source files are located, are on the desktop. I can compile the program using the makefile. The program does start up and runs until it is required to read from the .dat file. BTW, What is termcap? Again i appreciate your help on this matter. Eldwin |
|
|
|
|
|
#9 |
|
Prospect
Join Date: Apr 2003
Location: Turn...around...
Posts: 34
|
Maybe there's a command in your ~/.tcsh that's trying to access the /etc/termcap. Just a suggestion...
__________________
-Phil iBook G3 800 / 256MB / OS X 10.2 Macintosh SE 68k 7.5 MHz / 4MB / OS 6.08 (LOL) |
|
|
|
|
|
#10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
Whoah - slow down a minute. Let's start from the point where you are logged on your Mac. I'm assuming you are typing on the keyboard of the Mac - not doing a remote login to a Mac from some other machine. Ok then you double-click on Terminal in the Utilities folder and a new Terminal window opens. You don't need to enter your username & password in this window since you are already logged into the Mac. Does this correspond with what you are doing? You make it sound different when you talk about typing your name & password after mentioning Terminal. (added afterwards:) Oh - now I see that you said that you type in the command 'login'. Don't do that - you are already logged in. (I tried typing 'login' as you do and I see that same error about termcap - strange - I'll investigate why this happens but anyway, just avoid the 'login' and all should be well.)
If you are saying that you get an error message about termcap after starting a new Terminal window, this definitely means that djhyp3rion is right - you have something in your "dot" files (e.g. ~/.cshrc, ~/.tcshrc, ~/.login, etc) that is causing this. It would be something that you added yourself as there is nothing like that there normally. So edit those files and remove anything suspicious by putting a comment character (#) at the start of the lines.
And then what happens?
Your answer is here: http://www.google.com/search?q=termcap Last edited by hayne; 05-03-2003 at 07:14 PM. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
#11 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
FWIW, this condition can be invoked thusly:
Code:
# normal login % echo $TERM vt100 % setenv TERM network tcsh: Cannot open /etc/termcap. tcsh: using dumb terminal settings. # bork'd
__________________
On a clear disk, you can seek forever. |
|
|
|
|
|
#12 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
TERM=network
Right. So it seems (I looked at the source for tcsh) that this is partly a case of a bad error message. The code is using the function 'tgetent' which queries the terminfo database (which is what replaces /etc/termcap on OS X - and many other UNIX variants).
Since for some reason the environment variable TERM is set to "network" when the /usr/bin/login program is run, it is looking for a terminfo entry for "network" and such doesn't exist. The tcsh code then complains about /etc/termcap not existing - which is a bogus error message. All the above was perhaps not of interest to anyone but myself - but the bottom line regarding the original poster's problem remains the same: Don't use the 'login' command when you are already logged in. |
|
|
|
|
|
#13 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
thank you, sir.
|
|
|
|
|
|
#14 |
|
Major Leaguer
Join Date: Jan 2002
Location: Midwest Not quite Normal
Posts: 416
|
Not just login?
Unless su calls login.
Code:
[dreamersound:~] williamt% su root Password: _su: Cannot open /etc/termcap. _su: using dumb terminal settings.
__________________
I have a Reason3 not to be grumpy and now I have a Rosegarden that works. Willy |
|
|
|
|
|
#15 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
su
I don't see that problem when I su to another user:
su fred I don't have root enabled, so can't try that but maybe you can try su-ing to some other user than root to see if this is only a difficulty with root. |
|
|
|
|
|
#16 |
|
Major Leaguer
Join Date: Jan 2002
Location: Midwest Not quite Normal
Posts: 416
|
Every user it seems.
Code:
[dreamersound:~] williamt% su tester Password: _su: Permission denied _su: Trying to start from "/Users/tester" _su: Cannot open /etc/termcap. _su: using dumb terminal settings. [dreamersound:~] tester% exit exit [dreamersound:~] williamt% su geraldin Password: _su: Permission denied _su: Trying to start from "/Users/geraldin" _su: Cannot open /etc/termcap. _su: using dumb terminal settings. [dreamersound:~] geraldin%
__________________
I have a Reason3 not to be grumpy and now I have a Rosegarden that works. Willy |
|
|
|
|
|
#17 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
what about 'su -' ?
What happens if you use 'su -' instead of 'su' ?
E.g.: su - fred This effectively does a login as that user. You might be seeing this "termcap" problem with su due to your 700 permissions. |
|
|
|
|
|
#18 |
|
Major Leaguer
Join Date: Jan 2002
Location: Midwest Not quite Normal
Posts: 416
|
Need .termcap
Here's the problem:
Code:
[dreamersound:~] williamt% setenv HOME=/Users/williamt SHELL=/bin/tcsh USER=williamt LANG=en_US PATH=/sw/share/Geomview/bin:/sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/X11/bin __CF_USER_TEXT_ENCODING=0x1F5:0:0 TERM=vt100-color TERMCAP=��� TERM_PROGRAM=Apple_Terminal TERM_PROGRAM_VERSION=81 ... Yes and su - works for the Permission denied message. So I put my .termcap and my .terminfo dir into the other users home dir and I can su - cleanly. The TERM=vt100-color thing is part of the color ls mod. Which now works for each user. (dang its hard to remember all the little hacks we do) I found this when I logged in as tester and started Terminal.app and up pops the "Cannot open /etc/termcap" message. I think I remember fighting this back when I first installed Jaguar too. Thanks
__________________
I have a Reason3 not to be grumpy and now I have a Rosegarden that works. Willy |
|
|
|
![]() |
|
|