Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

shell script problems

 
pavan bellari
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
pavan bellari
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic