Problem with script invoked from a keyboard shortcut

-EDIT-

I have solved my problem below by using a different program. Instead of xsel I am using xclip which basically does the same thing and works fine from a script invoked by a global hotkey.

-END EDIT-

Hi,

I've written a simple script to copy my email address into both the clipboard and the primary selection using a useful utility called xsel. This is so that I can assign a global shortcut key to the script to quickly paste my email address when needed.

#!/bin/bash

# Use xsel to copy email address to the clipboard and to the primary selection.

xsel < /home/user/scripts/email-address-in-this-file

xsel --clipboard < /home/user/scripts/email-address-in-this-file

# Play completion alert sound, test only to see if the script actually ran.
play -q "/home/user/Music/MiscSoundEffects/Beep_Done.wav"

When run from a terminal prompt, it works perfectly and I can paste the email address with <CTRL>V and by middle-clicking. However it does not work properly from the keyboard shortcut key - the script runs because the audio test sound plays, but my email address does not end up in the clipboard or in the primary selection.

If I use <Alt>F2 to bring up the Gnome 'Run Application' dialog box and enter the script's name the same thing happens (the audio test sound plays, but my email address does not end up in the clipboard or in the primary selection).

My guess as to what is happening is that there is a problem due to running the script in a shell instance which dies almost immediately.

I tried 3 ways around this, none fixed the problem:

1) I used the xsel option --keep in the xsel commands.

2) I got the xsel process Id using "$!" and then used "disown" on the process Id to disassociate the program from the shell instance it was running in. But I got "disown: : no such job" when run from the terminal command line - the job had finished before I could disown it.

3) I added "sleep 30" to the bottom of the script thinking that if I could get the shell instance to stay alive the email address might stay in the clipboard and in the primary selection.

None of these worked.

Any help sorting this out would be greatly appreciated. Many thanks.

PS. I will happily use another method of getting my email address into the clipboard or primary selection, I've used xsel because that was the only way I knew to do it.