Sineatos
Sineatos

Reputation: 1017

How to send a message to another user via Bash

I am writing a shell script, and I need to send a message to the other user.

If I write write user1 in trem, and then write the message and use Ctrl + D, the message will send to user1's trem successfully.

But I want to use a .sh file to send the message to user1 automatically, and I encountered the problem. I need to write the message by myself when I use the command write user1 each time.

Now I want to save the message in the script and every time I send the message, I don't need to write the message again. How should I do this?

Upvotes: 3

Views: 4385

Answers (1)

Eric Renouf
Eric Renouf

Reputation: 14500

You can pipe a file/string into it like

echo "message" | write <user>

Upvotes: 4

Related Questions