[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Forum] Re: [MacPerl] UNIX Perl problem



At 3:31 PM +0000 9/30/00, Sveinbjorn Thordarson wrote:
>I'm sorry I wasn't clearer in my first message.  The "Use Shell.pm" was a
>stupid typing mistake on my behalf, as was the omission of qw(write), by the
>way.  I'm not quite that new to Perl.  However, I need to be able to send a
>different message to various users when they telnet into the Linux box at
>regular intervals.  I was planning on using cron, and a perl script that
>uses who and write.  wall won't work because it targets everyone.  The
>message must be instantaneous and appear in the user's terminal.  Is there
>anything that lets you send a text message to a user in a single line?
>
>How do I print into the write command and then end it with the Control-D?
>That's the real issue.

I'm taking this to forum, as it's not a strictly macperl question anymore.

I think you're taking the wrong approach with using a cron job, and sending
a message to users from a different account.  If you have root, which it
really sounds like you do (or you shouldn't be writing messages to users
when they log in!), there's a bunch of better ways to do this.

For one, install a script into their .profile or equivalent, that would run
when they log in.  This would allow you to read & write to their console as
if it were stdin/stdout (always a better thing to do than screwing around
with write or wall or etc. (not /etc, mind you)).  In terms of customizing
the message, there's all sorts of ways to do this, including looking up who
they are from the environment.

Another idea is to use the Message Of The Day functionality that's standard
with a lot of systems.  See your man pages on motd for more info on this.

Another, bad, idea is to hack login or init to do what you want.  But like
I said, that's a bad idea.

-Jeff Lowrey



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-forum-request@macperl.org