I have two computers on a LAN both using Jaunty.
I "administer" both computers and have passwordless ssh access to both systems. I'm trying to write a script (or an alias) so that I can send notification bubbles to the computers remotely. Issuing the command
Code:
ssh -X user@host 'DISPLAY=:0 notify-send "TEST MESSAGE."'
at a local terminal works like a charm - the notification bubble containing the message appears on the remote screen.
Since the text "TEST MESSAGE." is just an example used here, and the message I will want to send will vary every time, "TEST MESSAGE." has to be made into a variable. If I create an alias on each system, such as
Code:
alias chat='DISPLAY=:0 notify-send'
I can log in remotely, and at the remote prompt, simply enter and the quoted text, along with the quotes, is appended to the end of the aliased command.
In trying to create an alias or a script - let's name it 'chat' in either case - that resides locally but uses SSH to execute a remote command, setting the variable is proving to be quite a headache. Since the structure should be the same as the above example, I have to pass along the double quotes as input. In trying to do so, I keep getting errors such as, "Invalid number of options," or, "No summary specified."
In using an alias, structured like so
Code:
alias chat='ssh user@host DISPLAY=:0 notify-send'
I can send messages to the remote computer and have them appear on screen, but only if they are one or two words long - three words produces the "Invalid number of options" error.
In using a script, I have to assign the "QUOTED MESSAGE" to a variable, otherwise I get the "No summary specified" error - the same error as if you went to a local prompt and typed without any text between the quotes.
In trying to nest the variable inside those quotes, like this
Code:
ssh user@host DISPLAY=:0 notify-send "$1"
again produces errors. Exchanging the $1 variable for $@ causes the error to switch from one to the other.
Can anyone offer me pointers as to how I would pass a quoted string as a variable into a simple one-liner like this?
Bookmarks