delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW |
X-Spam-Check-By: | sourceware.org |
MIME-Version: | 1.0 |
Date: | Sat, 17 Mar 2012 15:32:18 -0700 |
Message-ID: | <CAPEfNzs8rTVwiH0rvKgddwDqn_dA=4o8b4_=v3R3k6q9=1M7ng@mail.gmail.com> |
Subject: | Question regarding expect and ssh |
From: | Brian Crabtree <briancrabtree1 AT gmail DOT com> |
To: | cygwin AT cygwin DOT com |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.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 |
X-MIME-Autoconverted: | from quoted-printable to 8bit by delorie.com id q2HMWiRY024000 |
Been trying to get a password reset script working with expect and ran across a problem if I have a $ in the entered password it wraps the variable in {}'s. Not sure if I'm missing an option somewhere or doing something wrong. Newest version of cygwin available. I have tried wrapping with "'s and using \$ and \\$ and neither made a difference. I have confirmed that it is passing "{password1$}" as a full string as my password was changed to that with my initial testing. Thanks, Brian $ ./passexpect_reset.sh ipaddress username password1$ password2 spawn ssh -l username ipaddress -o StrictHostKeyChecking=no {password1$} password2 parent: waiting for sync byte parent: telling child to go ahead parent: now unsynchronized from child spawn: returns {6516} ============================== ====== passexpect_reset.sh: #!/usr/bin/expect -f exp_internal 1 set ipaddr [lrange $argv 0 0] set username [lrange $argv 1 1] set oldpassword [lrange $argv 2 2] set newpassword [lrange $argv 3 3] set timeout -1 # now connect to remote UNIX box (ipaddr) with given script to execute spawn ssh -l $username $ipaddr -o StrictHostKeyChecking=no $oldpassword $newpassword match_max 100000 # Look for passwod prompt expect "*?assword:*" send -- "$oldpassword\r" # Look for shell expect "*$username*" send -- "passwd\r" # Look for passwod prompt expect "*?assword:*" send -- "$oldpassword\r" # Look for passwod prompt expect "*?assword:*" send -- "$newpassword\r" # Look for passwod prompt expect "*?assword:*" send -- "$newpassword\r" # send blank line (\r) to make sure we get back to gui send -- "exit\r" expect eof ==================================== -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |