Operating System - HP-UX
1753879 Members
7633 Online
108809 Solutions
New Discussion юеВ

Re: Disable motd for "su" commands.

 
SOLVED
Go to solution
compiler
Frequent Advisor

Disable motd for "su" commands.


Hi.

I have some scripts that do:

su - user -c "command"

The problem is that the above shows the motd of the server, exactly like you were login in as "user".

I cannot redirect stdout nor stderr to /dev/null because I need the output of command execution.

Is there any way to "hide" motd message in this case while keeping it for standard logins?

Thanks.
3 REPLIES 3
Avinash20
Honored Contributor

Re: Disable motd for "su" commands.

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1246203
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Dennis Handly
Acclaimed Contributor

Re: Disable motd for "su" commands.

Only by removing that "-". You'll need to change your command to not depend on that user's .profile.

I'm not sure you want to fiddle with /etc/profile and use advanced AI technology to figure out whether su changed the name of users in your process tree.
James R. Ferguson
Acclaimed Contributor
Solution

Re: Disable motd for "su" commands.

Hi:

Instead of doing 'su -' which causes the user's profile to be sourced (read), build a file of all the environmental variables you normally want when you login to that user. Then you can source that file as a part of the user's profile _AND_ when you perform a simple 'su'.

Thus:

# cat myvars
#!/usr/bin/sh
export MYID=me

...now source this in the user's '.profile':

. ${HOME}/myvars

...and when you need to 'su' (for example):

# su jrf -c ". myvars;env|grep me;date"

NOTE carefully that to source you type a dot followed by whitespace, followed by the file to be sourced.

Regards!

...JRF...