Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zpty woes
- X-seq: zsh-workers 25045
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Jaime Vargas <jev@xxxxxxx>
- Subject: Re: zpty woes
- Date: Thu, 15 May 2008 18:03:12 +0100 (added by '')
- Cc: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- In-reply-to: <99E8D43E-EC34-48DB-A5AD-BFA197A3AAA3@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <34AE8142-F5DA-44FD-96BA-61BDE12BC74E@xxxxxxx> <200805151318.m4FDIvKS015244@xxxxxxxxxxxxxx> <20080515145054.GC5190@xxxxxxxxxxxxxxx> <99E8D43E-EC34-48DB-A5AD-BFA197A3AAA3@xxxxxxx>
On Thu, May 15, 2008 at 12:00:25PM -0400, Jaime Vargas wrote:
> Still doesn't work for me. Below is the modified script and the debug
> output.
>
> #!/opt/csw/bin/zsh
>
> set -x
>
> zmodload zsh/zpty
>
> die() {print -r -- $1 >&2; exit 1;}
>
> zpty scppty scp hello.world jvargas@xxxxxxxxxxxxxxxxxxxxxxxxxxx:~/
> zpty -t scppty || die "fuck"
> zpty -r scppty line "*:" || die "no password asked"
> zpty -w scppty "3lp&tbw"
> while zpty -r scppty line;
> do
> result+="$line"$'\n'
> done
> zpty -d scppty
> print $result
>
> I changed my credentials for security. Basically it now hangs waitng for
> password and doesnt' do anything. -- Jaime
>
> nerd% ./zpty-test.zsh
> +./zpty-test.zsh:5> zmodload zsh/zpty
> +./zpty-test.zsh:10> zpty scppty scp hello.world 'luser@host:~/'
> +./zpty-test.zsh:11> zpty -t scppty
> +./zpty-test.zsh:12> zpty -r scppty line '*:'
Had you printed $line, you'd have seen something like
"+myscript:", not "Passwd: ".
[...]
> +./zpty-test.zsh:14> zpty -r scppty line
[...]
As Peter said, if you don't provide with a pattern to look for,
zpty will look for NL characters.
That last zpty is probably still waiting because so far, it has
only received "Password: " and is waiting for a NL character
that will never come.
So, in your code above, you should wait for something more
specific than just ":":
zpty -r scppty line "assword: " || die "no password asked"
for instance.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author