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?
Advertisement
Answer
You can pipe a file/string into it like
echo "message" | write <user>