3

Hey All, wrote this script to confuse my girlfriend when she is using my computer. The only trouble is that if the terminal gets closed the script stops to execute. It currently executes in the background but how can I make it run in the background but not in a terminal?

(sleep 5; say "Hello Girlfriend")&
akira
  • 61,009
  • 17
  • 135
  • 165
sixtyfootersdude
  • 8,049
  • 16
  • 52
  • 71
  • So where do you ultimately want to show her the message? – John T Feb 10 '10 at 05:14
  • 1
    If it's not running in a terminal, how do you expect to see the output? – pavium Feb 10 '10 at 05:15
  • 4
    @John T and pavium: the say command on Mac OS X is a voice to text to voice command. Ie: the command will read the text and play it on the speakers. – sixtyfootersdude Feb 10 '10 at 05:21
  • I suppose she gets confused because it says "girl frinde" instead of "girl friend"? – Nathaniel Feb 10 '10 at 05:31
  • Actually, I *did* notice the word 'say', but not being a Mac person I didn't catch on. If anything I might have thought of the `say` function in Perl 5.10 – pavium Feb 10 '10 at 06:09

5 Answers5

4

Have you tried nohup?

nohup command >/dev/null 2>&1 &
Dennis Williamson
  • 106,229
  • 19
  • 167
  • 187
2

I promise that no matter how much she likes you, 5 seconds is too fast an interval. Really.

nohup (and in bash disown) will allow you to detach the process from the initiating terminal.

1

You could schedule it to run at a specific time with at or cron in the background.

John T
  • 163,373
  • 27
  • 341
  • 348
0

You can suspend execution by Ctrl-Z and then let it run in the background with bg ( background ).

If you want to bring it forth then fg or %.

AxeZ
  • 21
  • 1
0

use at or cron as john suggested, and then use wall to send her a message to her terminal.

akira
  • 61,009
  • 17
  • 135
  • 165