From: Walls R. W C. 75 CS/S. <Rob...@HI...> - 2002-09-09 18:18:24
|
I removed the explicitly added \n from the password ->send string. Now debug reports Sending '1derful^J' to spawn id(3) instead of the '1derful\n\012' it was sending. However, the intermittent hang still occurs. When things hang, Expect receives the password instead of 'New password'. That is: Waiting for new data ... 1derful instead of: Waiting for new data ... New password: (and THEN receiving the password from ->send) It's like the answer arrives before the question is asked... I tried chomping the input passwords, but that did no good. I am using Term::ReadKey to input the password. Could there be some buffer issues with just loading that module? I hard coded the password string "1derful\n" and did not use ReadKey at all and things seem to work consistently. I could get the password as an arg, but that puts the password on the screen. I could also use getc instead of ReadKey, but I don't know how to turn off echo. I tried system "stty cbreak </dev/tty >/dev/nul"; but that still echo'd. Anyway, I am just trying to change system and Samba passwords at the same time and do some other updates to files when I or my users change their passwords. Do you have any ideas on a better way to do this? I am sure it has been done before, and I'm not too proud to use someone else's code! Expect seems like the natural thing to use to glue things together, so maybe you've seen something like this (many times?) Thanks for the help. -----Original Message----- From: Roland Giersig [mailto:RGi...@cp...] Sent: Thursday, September 05, 2002 1:48 AM To: Walls Rob W Contr 75 CS/SCBS Cc: 'exp...@li...' Subject: RE: [Expectperl-discuss] Expect and passwd > Sometimes it fails 1st then starts working and other times it works > and them fails, if that makes any difference (or sense...) ... > Sending '1derful\n\012' to spawn id(3) OK, that was a subtle one: you are not chomping the entered password, so when you send it, it contains TWO \n. passwd clears it's readline buffer before reading the password, but depending things beyond control, the second \n might or might not be in the buffer to be cleared. If it's not cleared, the "Repeat password" prompt returns with an empty password, which clearly does not match the first one... Just remove the "\n" from the send and it should work reliably. Hope this helps, Roland -- RGi...@cp... |