X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=1.2 required=5.0 tests=AWL,BAYES_00,DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: sourceware.org Message-ID: <21442493.post@talk.nabble.com> Date: Tue, 13 Jan 2009 11:16:27 -0800 (PST) From: blazt To: cygwin AT cygwin DOT com Subject: Re: automate SSH-HOST-CONFIG In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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 Dimitri, thanks for your help. I created the script based on yours but it never sends the expect back to the program. #!/bin/bash #!./expect -f chmod +r /etc/passwd chmod +r /etc/group chmod +x /var echo "Starting Script" ssh-host-config # Host keys generation is lengthy procedure set timeout 20 expect { "*** Query: 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" exp_continue} "Say "no" if it is already installed as a service) (yes/no)" { send "yes\r" exp_continue} "Enter the value of CYGWIN for the daemon: [ntsec]" { send "\r" exp_continue} "Do you want to use a different name? (yes/no) " { send "no\r" exp_continue} "Please enter the password for user 'cyg_server':" { send "password\r" exp_continue} "Reenter: " { send "password" } } echo "end First Part" 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" } } I took out the exec so I could see the script run and it simply hangs at the first query where it asks to overwrite existing files. Is there anything else I need to do to get this to work with cygwin? Dmitry Semyonov-2 wrote: > > 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/ > > > -- View this message in context: http://www.nabble.com/automate-SSH-HOST-CONFIG-tp21383170p21442493.html Sent from the Cygwin list mailing list archive at Nabble.com. -- 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/