Find the answer to your Linux question:
Results 1 to 3 of 3
I posted this on the Admin forum also. I wasn't sure which forum to use since it involves both administration and shell scripting. I'm having a problem when I install ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Nov 2002
    Posts
    420

    Startup script error


    I posted this on the Admin forum also. I wasn't sure which forum to use since it involves both administration and shell scripting.

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

    www.kornshell.com

    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?????????

    Help!

    BTW, if this question is too complicated for this kind of forum, does anyone know any other really good programming forums for linux specific issues like the above?

  2. #2
    Linux Enthusiast
    Join Date
    Jun 2002
    Location
    San Antonio
    Posts
    621
    First off, let me say, that is one of the best questions I have seen on this forum. First you define your setup, describe your problem, then say what you think is going on. You are right on the money. I searched google and found this. It was on the "howto make danish your default charset" or something crazy like that. I hope this helps. Also, did you ever here about David Korn going to a MS publicity meeting? Yeah, they started talking about how they had the full implimentation of the korn shell, etc etc. and David stood up, and posed the issue that they did not have full implimentation, as they did not support (insert like three obscure features here) and the Microsoft guy told him he didn't know what he was talking about, and that wasn't part of the shell, and etc. etc. Either way, he let it drop and came up to the guy after the press left and said basically "did you know who you were talking to" "No." "I didn't think so". Anyway, here is what I found.

    3.1. Loading the Latin-1 character set on the console

    Execute the following commands under the bash shell:

    setfont /usr/lib/kbd/consolefonts/lat1-16.psf
    mapscrn /usr/lib/kbd/consoletrans/trivial
    echo -ne '\033(K'

    You could also choose to load a Unicode font, which (in my opinion) is
    much nicer than lat1-16.psf and seems to be more stable:

    setfont /usr/lib/kbd/consolefonts/iso01.f16
    mapscrn /usr/lib/kbd/consoletrans/iso01.uni
    echo -ne '\033(K'

    If you use Linux kernels v1.3.1 or higher, you don't need the mapscrn
    and echo statements when you use Unicode fonts.



    Stolen from google groups.
    I respectfully decline the invitation to join your delusion.

  3. #3
    Linux User
    Join Date
    Nov 2002
    Posts
    420
    wassy121: You rock. You are the head guru!

    Thank you for your help. Even though it may be unnecessary, 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'd never needed to use terminal commands before.

    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.

    Happy hacking!

Posting Permissions

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