From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3649 invoked by alias); 16 Jan 2013 07:10:41 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17569 Received: (qmail 27696 invoked from network); 16 Jan 2013 07:10:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:subject:message-id :mime-version:content-type; s=mesmtp; bh=AEag3JAdabjtjzHyt/zC5Ba Yd3w=; b=Nw5yjkZjcHp+/ccsV/9pgst2yr6ORtTaOWXg/MXx4ed1HNyQF46eLcK FXOf+dA4h9Np76nrUbOnE8rORe61+T+Yd1hzuMhWyLwAQPcL/hqKrpnOdAZrSc/i 67L662pURaRt69beO0/rDdYgUqpyirRYyNRhXOdscMbPMeRN3OCo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:subject:message-id :mime-version:content-type; s=smtpout; bh=AEag3JAdabjtjzHyt/zC5B aYd3w=; b=ObgV7q43I6Rs6f8Rwwesw0xF1Feeeti4+4fBS07Jzxa+/pYzRpFcFd Mxthq9bhSKpmj+mQHbBDDFNsqiPSqC9LZ0//jEeRhgM2Jj0/uuiQ7RpbpPu5WZCz wMuEFurLYiKpHwqacxyDrxFk0Sl0CCdYT01Cp4i11dzsXsuMdr2Cg= X-Sasl-enc: 1YxqNWRbno7UGdJpRCnasFhCR5HwY4vxEfP7TS4dPFKd 1358319634 Date: Wed, 16 Jan 2013 08:59:51 +0200 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Backgrounding part of 'ssh-agent $cmd' Message-ID: <20130116065951.GA2992@lp-shahaf.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) tldr: I have a piece of code that prompts for password and then establishes N ssh connections in the foreground, and I'd like the SSH connections to be established in the background. More specifically, my workflow involves establishing several 'ssh -MNf' connections every morning, and running a command that prompts for a password: foo_ssh_preseed() { ssh-agent sh -x -e -c ' ssh-add ~/.ssh/foo.id_rsa for h in host1 host2 host3; do ssh -MNf $h & done wait ssh-add -D' } foo_main() { foo_ssh_preseed # the workaround places an 'if' around this line foo_internal # prompts for password; is interactive/long-running } Right now, what happens is: ssh-add prompts for password I wait while SSH connections are being established foo_internal prompts for password I can avoid the delay by running foo_ssh_preseed() in a new terminal emulator tab; or by running it directly in the same tab, ^Zing it, and then running foo_internal (while foo_ssh_preseed is doing its work). I'd like to remove the complication of an extra tab or explicit ^Z: I'd like the workflow to be Run foo_main Answer ssh-add password prompt # No interactive wait at this point. Answer the foo_internal password prompt (Use foo; the -MNf's will finish in a second or two.) Thoughts? Thanks, Daniel