Professional Web Applications Themes

text login to X - Linux / Unix Administration

Hello, I am a programmer pressed into sysadmin duties in a small office because I'm the most technical person there. I can handle it because we don't need anything too complex. The problem is that I'm not always available. Trying to anticipate situations where I don't have any access beyond a cell phone to talk to someone at the office, I want to set up the system so that a novice can look at the display and at least give me a few diagnostics and maybe even click a button to restart a service if necessary. This would be much ...

  1. #1

    Default text login to X

    Hello,

    I am a programmer pressed into sysadmin duties in a small office because
    I'm the most technical person there. I can handle it because we don't
    need anything too complex.

    The problem is that I'm not always available. Trying to anticipate
    situations where I don't have any access beyond a cell phone to talk to
    someone at the office, I want to set up the system so that a novice can
    look at the display and at least give me a few diagnostics and maybe
    even click a button to restart a service if necessary. This would be
    much easier (safer) than trying to dictate cryptic commands over the
    phone. However, I don't want to run X on the servers all the time - I
    want a text-based login prompt.

    How can I configure these novices' accounts so that a text-based login
    launches a X11 session when they are at the console, and be
    automatically logged out when they kill that session? Once I'm there,
    it would be easy to pop a couple xterms displaying system status and
    write some minimal "control panel" to restart essential services.

    Any ideas?

    Thanks,
    Tim
    Timothy Guest

  2. #2

    Default Re: text login to X

    In article <CYvUf.724$bX5.274dukeread04>,
    Timothy Larson <net> wrote:
     

    Put "startx" in their .profile, like we did in the old days before the
    nice GUI login window.

    --
    Barry Margolin, mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***
    Barry Guest

  3. #3

    Default Re: text login to X

    Barry Margolin wrote:
     

    Won't that dump them to the shell when they quit X? I'm trying to avoid
    that as well. Don't know if I can trust them (yet) to remember to log
    out "again".

    Tim
    Timothy Guest

  4. #4

    Default Re: text login to X

    Timothy Larson wrote: 
    > Won't that dump them to the shell when they quit X? I'm trying to avoid
    > that as well. Don't know if I can trust them (yet) to remember to log
    > out "again".[/ref]

    If you put something like this in their .profile, they won't have much
    opportunity to continue after startx exits:
    exec startx
    logout
    exit

    Michael Guest

  5. #5

    Default Re: text login to X

    In article <googlegroups.com>,
    "Michael Paoli" <com> wrote:
     
    > > Won't that dump them to the shell when they quit X? I'm trying to avoid
    > > that as well. Don't know if I can trust them (yet) to remember to log
    > > out "again".[/ref]
    >
    > If you put something like this in their .profile, they won't have much
    > opportunity to continue after startx exits:
    > exec startx
    > logout
    > exit[/ref]

    No need to logout if you use "exec", since when startx exits there's no
    shell process any more.

    --
    Barry Margolin, mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***
    Barry Guest

  6. #6

    Default Re: text login to X

    Barry Margolin wrote: [/ref]
     

    Defensive programming. If any shell continues beyond execution of the
    exec (such as if the exec fails) then the logout and exit should
    ensure the shell quickly terminates following the exec. If someone
    intentionally or otherwise alters the exec line such that it becomes
    inoperative, again, the logout and exit are there to quickly terminate
    the shell.

    At quick check, it would appear most (all?) shells will not proceed
    beyond the exec statement - even if the command is invalid, doesn't
    exist, cannot be executed, etc. That, however, doesn't ensure there
    are and will be no exceptions. Some languages will proceed beyond an
    exec if the exec cannot be done successfully (e.g. the program doesn't
    exist).

    Maybe I should have better commented the suggested code :-) :

    exec startx
    # we shouldn't be able to get here, but if we do, we don't want the
    # user to have direct interactive shell launched
    logout
    exit

    This is why it's also often useful (and sometimes important or
    critical) to put appropriate code in what *should be* unreachable
    sections of code. They well cover the "oops" factor, giving
    safer / better / more predictable behavior in what are often already
    adverse situations or unusual error states.

    Principle of least surprise, etc.
    http://www.rawbw.com/~mp/unix/sh/#Good_Programming_Practices

    Michael Guest

  7. #7

    Default Re: text login to X

    Barry Margolin wrote: 
    >
    > No need to logout if you use "exec", since when startx exits there's no
    > shell process any more.[/ref]

    But does the .profile (or whatever) run in a subshell, or in the login
    shell's process? If a subshell, you'd still have the login shell alive
    after X was killed.

    Tim
    Timothy Guest

  8. #8

    Default Re: text login to X

    On 2006-03-26, Timothy Larson wrote: 
    >>
    >> No need to logout if you use "exec", since when startx exits there's no
    >> shell process any more.[/ref]
    >
    > But does the .profile (or whatever) run in a subshell, or in the login
    > shell's process? If a subshell, you'd still have the login shell alive
    > after X was killed.[/ref]

    Since the purpose of .profile (or whatever) is to set variables in
    the current process, of course it is not run in a subshell.

    --
    Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence
    Chris Guest

Similar Threads

  1. Replies: 4
    Last Post: September 18th, 11:58 PM
  2. P text files based on login
    By cfdoogan in forum Coldfusion - Advanced Techniques
    Replies: 3
    Last Post: February 27th, 04:25 AM
  3. Replies: 1
    Last Post: November 24th, 08:24 PM
  4. Replies: 0
    Last Post: June 25th, 06:36 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139