From owner-freebsd-questions@FreeBSD.ORG Sat Jul 28 05:59:27 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9E4E016A419 for ; Sat, 28 Jul 2007 05:59:27 +0000 (UTC) (envelope-from cptsalek@gmail.com) Received: from mu-out-0910.google.com (mu-out-0910.google.com [209.85.134.188]) by mx1.freebsd.org (Postfix) with ESMTP id 3B24113C465 for ; Sat, 28 Jul 2007 05:59:26 +0000 (UTC) (envelope-from cptsalek@gmail.com) Received: by mu-out-0910.google.com with SMTP id w9so1060683mue for ; Fri, 27 Jul 2007 22:59:25 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=hINYbODsiE5CyVTSQyDHDaeqMS/V8mabbJRy6v03II8W3NzOA92mu1vZ9FKUgvLF/mg0eUg+yL3rqW6g47GexxCu6eGXvFUGMm6BFCBT8ExSDi4C0nsPWQqOP4nANZwx7+Pibs8pTMLYCgN11zV3Xz7P9f4AUbOXj6PeTxyBfys= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=m26+23RzNBlcdvwGU+oo2nwevLUzJ/59oCS2ZrlsXXKACZbt8/RmFFn4DWlbWP4MpB5Ftm2T/cgtq5M7Agm6xGtsiNhKaZUuIpXexVOxszdsKDTIN4k6C4obnavTAqTHosacvb3cd2W22HiUhiR2IZK63z6x2J0vUKhhD53Z5YI= Received: by 10.82.190.2 with SMTP id n2mr3123580buf.1185602365711; Fri, 27 Jul 2007 22:59:25 -0700 (PDT) Received: by 10.82.171.9 with HTTP; Fri, 27 Jul 2007 22:59:25 -0700 (PDT) Message-ID: <14989d6e0707272259hadcf41fo8dd987fe5136ec7b@mail.gmail.com> Date: Sat, 28 Jul 2007 05:59:25 +0000 From: "Christian Walther" To: "Martin McCormick" In-Reply-To: <200707271953.l6RJrsXo086613@dc.cis.okstate.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200707271953.l6RJrsXo086613@dc.cis.okstate.edu> Cc: freebsd-questions@freebsd.org Subject: Re: Remote Execution of sudo Command Hangs. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jul 2007 05:59:27 -0000 Hi Martin, On 27/07/07, Martin McCormick wrote: > We have 3 FreeBSD systems. One is trying to use ssh and sudo to > run commands on two other systems. The remote command being > executed is: > > ssh remote.system.domain sudo dhcpreset > > dhcpreset is an expect script most of which is shown > here: [Script removed] > > The script works perfectly if you run it from a login > shell on the system where it actually lives as in: > > sudo dhcpreset. > > If you run it via ssh from a remote system, however, it > runs, produces the proper status messages and does its job and > then . . . . . . > > You have to hit a Control-C to kill off the ssh > connection which doesn't drop on its own. > > I think my script must somehow make sudo not see the > exit. Even though you see the dhcpd -q process started as a > background process, dhcpd daemonizes almost immediately and you > even see the completion message in a log of the activity so it > isn't that. Besides, it exits properly when called locally. > > Other remote commands using sudo properly exit. Any idea > how I might figure out what is hanging things up? > > If you do a ps on the remote system, the expect script > has ended. On the calling system, you still see ssh to the > remote system. > > Reading the expect manual shows an exit command but also > says that it is implied when the end of the script is reached. I > have tried it with and without that command at the end with no > effect. > > Thanks for any other suggestions for making this command > terminate when done. Try using "pseudo tty allocation" with your ssh command, it's the "-t" option. So, use "ssh -t remote.system.domain sudo dhcpreset" as the command. If this doesn't work directly, you can even try several "t"s. I had best results with -ttt. If this still doesn't work, try using "nohup dhcpd -q" as command. HTH Christian