Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Jul 2007 05:59:25 +0000
From:      "Christian Walther" <cptsalek@gmail.com>
To:        "Martin McCormick" <martin@dc.cis.okstate.edu>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Remote Execution of sudo Command Hangs.
Message-ID:  <14989d6e0707272259hadcf41fo8dd987fe5136ec7b@mail.gmail.com>
In-Reply-To: <200707271953.l6RJrsXo086613@dc.cis.okstate.edu>
References:  <200707271953.l6RJrsXo086613@dc.cis.okstate.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Martin,

On 27/07/07, Martin McCormick <martin@dc.cis.okstate.edu> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14989d6e0707272259hadcf41fo8dd987fe5136ec7b>