# Embedding uptime into terminal welcome message?



## Gwailo (May 14, 2002)

Right now my /etc/motd is


> Welcome to Helios;
> AUTHORIZED PERSONNEL ONLY



I would like to insert the ``uptime`` at the end of that. Is that a login script, or is it possible to embed commands into ``/etc/motd``? I have no idea how to make login scripts 

Thanks!


----------



## nkuvu (May 14, 2002)

You can edit your .login file (use ls -a at the prompt to see it) to execute commands on login.  I'd just try to add uptime to the end of the .login file (or create a new file if it's not there).  If that doesn't work, post again and we'll get something going.  The file should be in your home directory, btw.


----------



## Gwailo (May 14, 2002)

> Welcome to Helios;
> AUTHORIZED PERSONNEL ONLY
> 
> 9:05PM  up 2 days,  1:35, 2 users, load averages: 0.81, 0.41, 0.34
> [localhost:~] gwailo%



Excellent, thanks! I had to create the ``.login`` file, but it does execute it after ``/etc/motd`` to display the above perfectly.

Cheers!


----------



## sao (May 18, 2002)

You can also do it with 'precmd'.

 From the tcsh man pages:

 Tcsh supports a special alias, precmd, which if set holds a command that will be executed before printing each prompt. For example, if the user has done

   alias precmd date

 then the program date will be run just before the shell prompts for each command. There are no limitations on what precmd can be set to do, although discretion should be used.


 Cheers...


----------



## Kris (May 18, 2002)

This question is a bit like the one above..

I want the /etc/motd file to greet every user when they open their Terminal window. I wrote a small script that handles this, but when I put it into the /etc/motd, I see the whole script when I open a Terminal window, even though the compilation seems to go well. Where shall I put the script?


Kris


----------



## nkuvu (May 18, 2002)

The MOTD is just read as a text file, it's not in itself executable.

So once the script is written and chmod'ed to be executable (and runs fine from a command prompt) just put it in the .login file.  That file is the list of things to execute upon login.  Would this not work for what you are doing?


----------



## Kris (May 18, 2002)

I thought about that, but it will only work for me, not for the other users. But doesn't the shell have some sort of main-defaults file that it reads from? Can the script be placed there?


Kris


----------



## lethe (May 18, 2002)

a related question:

there was once a user on my school server whose .plan file seemed to be executing.  what i mean is, when you finger the user, instead of just seeing the text contents of the file, i would see text that displayed with pauses in it, and would wait for you to type something before it would go on.

it seemed like a script, or even compiled code, whereas i thought that the finger program only just dumps text from the .plan file, much like the motd file.

this user also had code running so that he knew when people fingered him.  he also had a way of replacing the remote host that showed up when you finger him.  

i don t know how he did any of that stuff, and he wouldn t tell me.


----------



## Kris (May 18, 2002)

Thank you testuser, it works! 

What does the perl line actually do?


Kris


----------



## nkuvu (May 18, 2002)

The perl line just prints two newlines, then /users/Kris/doOnLogin followed by another newline.  It's the >> that does the work here.  That part just appends what was written to the end of the /usr/share/init/tcsh/login file.


----------



## Kris (May 18, 2002)

I opened the loin file (becuase I wrote something wrong the first time) and I saw it. 
The perl-sentence is actually pretty logical (at least when you know what it does.. ) I recognised the "\n" form other programming languages, but it was the ">>" that confused a bit. I get it now.

Thanks again everyone. 


Kris


----------



## Kris (May 19, 2002)

> _Originally posted by testuser _
> *These are very private files that you should open only if you know what you are doing *


 

Kris


----------

