aspose file tools*
The moose likes Linux / UNIX and the fly likes shell script problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "shell script problems" Watch "shell script problems" New topic
Author

shell script problems

pavan bellari
Greenhorn

Joined: Sep 19, 2003
Posts: 24
There are 3 questions. pls reply this
-----------------------------------------------------
how to execute wall command in shell script
desc:
how to pass messages to users logged in thru wall command from shell script
-----------------------------------------------------
how to change directory(cd command) from shell script
for eg:
in shell script i have given cd/home
but when i execute shell scipt the directory remains the same with out change.
-----------------------------------------------------
how to flash a message when user logs in
desc:
to give a message from root to a particular user so that when ever the user logs in, the first message must be "Contact System Administrator" and system should not allow the user to do any thing further. only message should be flashed
-----------------------------------------------------
thanks in advance
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by pavan bellari:
There are 3 questions. pls reply this
-----------------------------------------------------
how to execute wall command in shell script
desc:
how to pass messages to users logged in thru wall command from shell script


As the man page says,
wall "message"
Is there a problem?


-----------------------------------------------------
how to change directory(cd command) from shell script
for eg:
in shell script i have given cd/home
but when i execute shell scipt the directory remains the same with out change.


The "cd" command only affects the shell it's executed in; if you run a script in a subshell, cd commands in the script won't affect the original shell. You can "source" a shell script instead of executing it; this will read the file and execute the commands in the current shell. So instead of
machine% foo
you'd type
machine% source foo



how to flash a message when user logs in
desc:
to give a message from root to a particular user so that when ever the user logs in, the first message must be "Contact System Administrator" and system should not allow the user to do any thing further. only message should be flashed
-----------------------------------------------------
thanks in advance

I'm not familiar with a specific tool that would help you in this antisocial practice, but if you replace the user's default shell with a program that displays that message, then you'd get the desired effect -- i.e., edit /etc/passwd and replace /bin/bash with /sbin/rudemessage for that user. You'd have to put /sbin/rudemessage in /etc/shells.
(Note that /sbin/rudemessage is a program you'd have to write yourself.)


[Jess in Action][AskingGoodQuestions]
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
I'm not familiar with a specific tool that would help you in this antisocial practice, but if you replace the user's default shell with a program that displays that message, then you'd get the desired effect

i think i will try this!


what?
pavan bellari
Greenhorn

Joined: Sep 19, 2003
Posts: 24
I don't want to do anti social things.
I am doing a project for system administrator. I want to issue a message to a user like
"Contact system administrator and i want to suspend the user from work until he contacts system admin"
so tell me how to issue a message immediately when ever the user logins
and he should not be allowed to enter to his login. or suppose if he already login, a message should come and the work must be suspended.
thanks in advance
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

I already told you how to do it. Write a program that prints the message, then exits.

Compile it, put it in /bin/rudemessage. Then edit /etc/password to make /bin/rudemessage be that user's default shell. They could still FTP in and get some of their files, if FTP is enabled; but they couldn't log in via telnet, ssh, rsh, etc.
 
 
subject: shell script problems