I'm new to shell scripting and am having a problem trying to do something in C shell. I want to write a script that will input something instead of a user doing it. For example, using the command 'write' the user is supposed to type something to be sent to another user. I want a script to be able to send the message.
write is an interactive command (do a man write).. so it can't be used in scripts... there are no non-interactive options that I know of with write...
by default you are not permitted to write to another terminal... both users should allow write using the "mesg" command...
Cheers!
Vishnu.
write can be used in scripts (at least the versions I've used).
#! /bin/sh
echo "\nHello there!\n" | /usr/bin/write username
or if you've got a longer message, this should work:
#! /bin/sh
/usr/bin/write username <<EOF
Hello there!
I was just
looking though
all of your files,
and found your
purity test! You
dirty bird, you!
EOF