delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/01/13/03:48:48

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <ddc185be0901130048l3bea8c66v5b49098454113769@mail.gmail.com>
Date: Tue, 13 Jan 2009 11:48:01 +0300
From: "Dmitry Semyonov" <linulin AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: automate SSH-HOST-CONFIG
In-Reply-To: <21427082.post@talk.nabble.com>
MIME-Version: 1.0
References: <21383170 DOT post AT talk DOT nabble DOT com> <21427082 DOT post AT talk DOT nabble DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Hi Johnny,

On Tue, Jan 13, 2009 at 03:28, blazt wrote:
>
> I am not sure how to do a except script. I have been looking at what I can
> find on the net.

It is 'expect', not 'except'. It's enough to read 'man expect' for basics.
You'll have to learn some Tcl docs for advanced usage, (not required
for ssh-host-config automation).


> Would I pass this command into the except part?

See an excerpt from my expect script below. I don't provide the full
version, as it is complicated more than necessary for the
demonstration due to support of different OSes and corner cases. (Also
it was not verified with the latest ssh-host-config.)


#!/bin/expect -f

# required on Win2k3
exec chmod +r /etc/passwd
exec chmod +r /etc/group
exec chmod +x /var

spawn ssh-host-config

# Host keys generation is lengthy procedure
set timeout 20

expect {
  "Overwrite existing /etc/ssh_config file? (yes/no)" { send "yes\r";
exp_continue }
  "Overwrite existing /etc/sshd_config file? (yes/no)" { send "yes\r";
exp_continue }
  "Should privilege separation be used? (yes/no)" { send "yes\r" }
}

set timeout 5

expect {
  "Should this script create a local user 'sshd' on this machine?
(yes/no)" { send "yes\r" }
  "new local account 'sshd'? (yes/no)" { send "yes\r" }
}

# [skipped]

expect eof { exec cygrunsrv -S sshd }


-- 
...Bye..Dmitry.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019