Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    More Unix Shells

    I'm having a problem when I install the korn shell.

    You can get a standalone binary for the ksh93m, or download the source code from the above URL. I just got the binary. Thank you AT&T! That's a first, eh?

    For those who have never tried ksh93m, I consider it much better than pdksh, if you've ever compared the two. Especially since ksh93m was written by David Korn!

    Anyway, here's the problem when installing the ksh93m on Mandrake-Linux 9.0. When I use ksh as my login shell, i.e. per chsh, I get some weird garbage on the terminal after I log in.
    It looks like this:
    -e \033(K

    I traced it down to the file: /etc/init.d/mandrake_consmap

    The garbage is coming from the following line in the above file:
    echo -n -e '\033(K' 2>/dev/null > /proc/$$/fd/0

    Any experts out there have an idea on what that is doing?
    Very cryptic, huh?!!

    The command is failing in ksh because of the echo command.
    Just as an FYI, echo is a built-in shell command not an executable.
    In ksh, echo does not have the [-e] option.
    That's why it's failing.
    But before I figure out how to fix it, I'd like to figure out what that line is supposed to be doing.

    Basically, it's outputing that strange string to /proc/$$/fd/0, and sending all errors to /dev/null.
    Now, /proc is the filesystem which represents the internal memory.
    The memory used by every process is represented in the /proc filesystem, right?
    The value of $$ is the process id of the currently running shell.
    fd stands for file descriptor and 0 would be the input file descriptor
    So, basically, it is sending the string '\033(K' to the input file descriptor of the currently running process.
    Are you following me, so far? If so, is my logic correct?
    If so, why in the world did the programmer do that?
    To show off or something? What is it supposed to do?????????


    BTW, if this question is too complicated for this kind of forum, does anyone know a really good programmer's forum for linux specific issues like the above?

  2. #2

    I'm not a Mandrake user, but that looks to me like a terminal command. You can send commands to terminals by echoing characters like that. \033 is the escape character, which usually begins a terminal command. This stuff can be used for things like setting your terminal's title bar. But every terminal type has different command sequences, so sending the commands to the wrong terminal can do weird stuff. Of course, these days, everyone has terminal emulators rather than terminals, but it amounts to the same thing. Your current terminal type should be in $TERM. Probably it is "xterm" if you're using a GUI. If you have a remote connection, it will probably be "vt100" or "vt102."

    I don't understand why you'd use such a command in an init script, nor do I understand why this would be shell-specific. But hopefully this info can give you a place to start looking for answers.


  3. #3

    That definitely gives me a place to start. I was at a dead end.
    Terminal command, eh? Interesting....

    I am connecting straight from the command line when it starts up, so that would be /dev/vc/1. The value of $TERM is 'linux'.

    I didn't mean to give the impression that the terminal command is shell specific. It is not. The echo command is shell specific. Different options are available in bash for echo than in ksh. The -e options works in bash and zsh but not in ksh93m. Anyway, on the Mandrake distribution there is a generic set of /etc/profile scripts that run no matter what shell you use to login. Not on the init process that starts the kernel, but only when a shell is started during login.

    I found the Text-Terminal HOWTO on
    I just need to dig through that for a while I guess.

    Thanks for your help!

  4. $spacer_open
  5. #4
    Linux Enthusiast
    Join Date
    Jun 2002
    San Antonio
    in response to pjungwirth: Read my other comment on this topic, it is full of insight as to WHY it would want to be done on init. And it is shell specific because of the echo command. I am sure it could be modified ever so slightly to do exactly what it was supposed to do (which turns out to be nothing) by removing the -e flag, but I am not sure of that. Good ideas though.
    I respectfully decline the invitation to join your delusion.

  6. #5
    wassy121: Now you have me curious. But what other comment?


  7. #6
    pjungwirth: I posted this same topic in the General Scripting forum

    That's what wassy121 meant by comment. It's in that forum. Check it out.

    Thank you both for your help. I found a fix to the problem. It was quite easy and I'm quite embarrassed that I even raised the discussion other than the benefit of discovering more about the inner workings of mandrake-linux.

    I modified the line:
    echo -n -e '\033(K' 2>/dev/null > /proc/$$/fd/0

    to read:
    /bin/echo -n -e '\033(K' 2>/dev/null > /proc/$$/fd/0

    Apparently, at least under Mandrake-Linux 9.0, echo is included as a separate binary. In the korn shell it is a built in command. By changing to the full path of the echo executable, I forced the korn shell not to call it's built-in echo command which does not have the '-e' option.
    Simple really, but maybe not very intuitive.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts