Search code examples
bashsignalssendgnu-screen

Send Ctrl-A and Ctrl-D from shellscript to a GNU screen


How can I send the signals of CTRL-A and CTRL-D from a shell script to a screen? Next code doesnt work to me. Screen process still is running in foreground and I want that it executes in background. Any idea?

#!/bin/sh
#TweetBot notifications with Growl

cd ~/node-tweetbot/
screen -S "tweet" node app.js -X stuff "'^A' '^D'"

Solution

  • You could simply start up screen in detached mode. From the man page:

       -d -m   Start screen in "detached" mode. This creates a new session but
               doesn't  attach  to  it.  This  is  useful  for  system startup
               scripts.
    

    So this:

    screen -S tweet -d -m node app.js
    

    Would start up your screen session detached. You could attach to it at a later time by running:

    screen -x tweet