bloodstorm17
bloodstorm17

Reputation: 521

Broadcast User Message to All Using Wall

so I want to let the user enter a specific message either by pasting it or typing it themselves using wall and by using wall, broadcast it to all users. I the idea is that I don't want to have only one line of message but rather allow for as big of a message that they want without using a text file.

I came up with this:

...
elif [ $var -eq 3 ]

        echo "Enter your broadcast message (When done, wait 2 seconds):"
        broadcastThis= read -d '' -n 1 message

        while broadcastThis=`read -d '' -n 1 -t 2 c`
        do
            message+=$c
        done

        wall <<< $message
fi

I get an error stating the following:

script: line 146: warning: here-document at line 141 delimited by end-of-file (wanted `$message') script: line 147: syntax error: unexpected end of file

I am really stuck at this point, it seems to have an issue on how wall is taking in the variable $message.

EDIT: I made the changes that devnull suggested but now only the first letter of the user's input is being broadcasted.

Upvotes: 0

Views: 333

Answers (1)

devnull
devnull

Reputation: 123468

<< denotes a here document.

What you're looking for is a herestring:

wall <<< "$message"

If you wanted a here document, you'd need to use the correct syntax:

wall << DELIMITER
"$message"
DELIMITER

Upvotes: 1

Related Questions