Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a script to deploy a project to multiple servers (9 and counting). With compression, copying, and remote connections, the script is rapidly becoming fairly slow. So now I'm investigating having the script trigger a helper run via screen. The ideal workflow in pseudocode is as follows:

deployment script
    accept user input for deployment parameters
    echo "deployment initiated"
    start helper 1 in detached screen, dumped to a temp file

helper 1
    export from SVN
    compress files
    upload to temporary directory on live servers
    swap old and new web directories on live servers
  * start helper 2 in $TTY

helper 2
    echo "deployment done"
    echo "do you want to view deployment log? [y/N]"
    take user input
    if yes
        output temp file
    delete temp file

Everything is simple enough except for the command marked with a *. I can pipe a static message to write $TTY, but to take user input I would need to execute a shell script from outside the terminal in which it is to be displayed. Is there any way to do this?

(I'm running CentOS on the dev server, by the way.)

share|improve this question
If you're making something for deployment, it should, be default, write a log file. If the user wants to view the log, they can exert the effort to do it themselves. Otherwise you're going to end up with people just running yes no | all the time, which is just a bit extra annoying, and unnecessary. tl;dr: make it non-interactive. – zebediah49 Jun 20 '12 at 19:02
The current script has its own logging, both to a database and a log file. However, these logs are just single lines indicating who deployed what and when. The temp file would be a full dump of everything presently returned by the script, including ssh connection messages, svn checkout, and so forth. In all, the output in the script as it stands is about 25 lines. Logging this to a permanent file is overkill. // The decision to make the command interactive is over my head. That's a must. It's mostly being used by PHP developers, many of whom have very minimal experience with the command line. – Mikkel Jun 20 '12 at 19:17
up vote 1 down vote accepted

You can launch helper 2 connected to TTY with a command like: >$TTY 2>&1 <$TTY

to redirect standard input, standard output, and standard error to TTY.

Unfortunately, there are problems with this approach:

  1. Once "deployment script" exits, the shell will be reading input from TTY to get the users next command. When both the shell and are attempting to read from TTY, where the users input goes is not predictable.

  2. If the user starts and editor or some other command after launching 'deployment script', the output from helper 2 will pollute what is on their screen.

Some alternative approaches:

  • Have deployment script wait for helper scripts to finish to prevent the shell from competing with helper 2 for the users input
  • Have helper 2 just email the developer the log without asking them if the want to see it
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.