Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!helps!uudell!pensoft!robin From: robin@pensoft.uucp (Robin Wilson) Newsgroups: comp.unix.aix Subject: Re: Is there a way to logout an inactive user after nn minutes? Message-ID: <1991May20.221557.9652@pensoft.uucp> Date: 20 May 91 22:15:57 GMT References: <7548@spdcc.SPDCC.COM> Organization: Pencom Software, Austin, TX Lines: 82 In article <7548@spdcc.SPDCC.COM> rbraun@spdcc.COM (Rich Braun) writes: >Switch to ksh, in any event; it's a much better shell. It uses >.profile for startup purposes. Actually, both "sh" and "ksh" use the ".profile" for startup purposes. So it is not really a good idea to use "ksh" specific commands (ie. ones not found in "sh") in this file. Instead I usually specify "ENV=$HOME/.kshrc" and then "export ENV" (note that the command syntax "export ENV='blah'" doesn't work in "sh", so this will cause you problems if you use it in your ".profile"). Why is this significant? Because "cron" uses "/bin/sh" as it's default shell. If you have "/bin/ksh" linked to "/bin/sh" this is not a problem; however you probably don't want to do this so that you will always have a bourne shell available. Beyond this, cron (yes it is a bug) on the RS6K reads the user's .profile at every command. If your ".profile" has some kind of request for input, or just output it will mess up cron (output will show up as a mail message with the subject: "The following is output from one of your cron commands" (or something like that) -- if you have several cron jobs going each day, you will be inundated with meaningless mail). Usually I try to setup "bourne shell" environments that don't require human intervention and don't have any output in the ".profile" file; while at the same time using the shell ENV variable to specify the environment for my interactive shells. BTW, the original question was about "TIMEOUT" variables for the shell. Here they are: /bin/sh == TIMEOUT /bin/ksh == TMOUT /bin/csh == timeout (I'm not sure of this one, I have never found a use for c shell... :-) ) Use whatever command is neccessary to set an environment variable for each of these. On both "ksh" and "sh" there is an environment "setting" tool called "readonly" which is used in place of "export". You would set the TMOUT and/or TIMEOUT variables like so: TIMEOUT=600 # shell timeout in seconds TMOUT=600 # ksh timeout in seconds readonly TIMEOUT TMOUT This would be added to the "/etc/profile" file, and then the users would not be able to "unset" these values on their own. >A question for those whose AIX and ksh knowledge surpasses my own: >is there a way for a sub-shell to export environment variables to its >parent, and/or is there a way to cause ksh to run a script in its >own context rather than within a subshell? (This is addressed via >the 'source' command in csh, but I know of no equivalent in ksh.) >For example, if I create a file called "setup" which contains the >statements The ksh/sh equivalent of "source" from csh is "exec" or just plain ".". For example, typing: . $HOME/.profile will re-execute your ".profile" and modify (if neccessary) your existing environment. So for a shell script that you always want to modify your current shell environment, you would use the following alias: alias script='. /script' NOTE: this only works in "ksh" since "alias" is not a command that "sh" recognizes. +-----------------------------------------------------------------------------+ |The views expressed herein, are the sole responsibility of the typist at hand| +-----------------------------------------------------------------------------+ |UUCP: pensoft!robin | |USNail: 701 Canyon Bend Dr. | | Pflugerville, TX 78660 | | Home: (512)251-6889 Work: (512)343-1111 | +-----------------------------------------------------------------------------+