Sample Header Ad - 728x90

Invoke a command/script disconnected from the controlling terminal?

10 votes
3 answers
9045 views
I'm investigating the behaviour of a script that is normally run as an automated process (e.g. cron, Jenkins). The script can (eventually) invoke commands that behave differently (seeking user input) when run interactively; for example, patch will ask what to do with a reversed patch, and svn will ask for passwords, but I need to see what happens when they're run non-interactively. Persuading patch that it's non-interactive is fairly easy; I just need to redirect stdout to be a non-tty: $ >(cat) /path/to/myscript --args However svn will connect to the controlling terminal if it exists; editing the scripts to pass --non-interactive isn't really an option as this is coming from several levels deep and it'd be difficult to be certain I'd found every invocation. Is there a way to invoke a script/command non-interactively, without a controlling terminal (so that /dev/tty doesn't exist)? I'd prefer stdout/stderr to still go to my terminal. (I found the question https://unix.stackexchange.com/questions/23892/run-script-in-a-non-interactive-shell but the answers to that discuss the differences between the cron and user environment; I've already eliminated all differences except non-interactivity.)
Asked by ecatmur (245 rep)
Mar 20, 2013, 03:43 PM
Last activity: Mar 15, 2020, 07:57 AM