From: "TJ Luoma" <luomat@gmail.com>
To: "Zsh-Users List" <zsh-users@zsh.org>
Subject: Re: How should I construct this?
Date: Wed, 24 Apr 2013 18:40:25 -0400 [thread overview]
Message-ID: <F0BC3EAB-7C1F-47C6-93C5-E64C5A6501A0@gmail.com> (raw)
In-Reply-To: <130424125052.ZM15513@torch.brasslantern.com>
On 24 Apr 2013, at 15:50, Bart Schaefer wrote:
> In addition to Thomas's hashtables remarks, zsh "for" also supports
> populating multiple variables each pass around the loop.
>
> So if you have an ordinary array like your example (BTW I hope those
> aren't your real passwords) then you can do
>
> for SSID WIFIPASS in $ALL_WIFI_NETWORKS
> do
> # Attempt to join network $SSID using $WIFIPASS
> done
The only drawback that I have found to this is that it ignores "" for
empty passwords
# INPUT
ALL_WIFI_NETWORKS=(
"Home" "89382ashfa"
"Work" "0823u2j98dyumn"
"Coffee House" ""
"Jenny's Wifi" "8675309"
)
for SSID WIFIPASS in $ALL_WIFI_NETWORKS
do
echo "SSID: ${SSID}\tPass: ${WIFIPASS}\n"
done
# RESULTS
SSID: Home Pass: 89382ashfa
SSID: Work Pass: 0823u2j98dyumn
SSID: Coffee House Pass: Jenny's Wifi
SSID: 8675309 Pass:
So I'll just use a single character to represent empty passwords, such
as
ALL_WIFI_NETWORKS=(
"Home" "89382ashfa"
"Work" "0823u2j98dyumn"
"Coffee House" "-"
"Jenny's Wifi" "8675309"
)
for SSID WIFIPASS in $ALL_WIFI_NETWORKS
do
echo "SSID: ${SSID}\tPass: ${WIFIPASS}\n"
done
and then check for a password equal to - before sending the command.
TjL
next prev parent reply other threads:[~2013-04-24 22:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-24 18:16 TJ Luoma
2013-04-24 18:39 ` thomasg
2013-04-24 18:56 ` TJ Luoma
2013-04-24 19:53 ` thomasg
2013-04-24 19:08 ` peter.d.miller
2013-04-24 18:49 ` Paul Hoffman
2013-04-24 19:50 ` Bart Schaefer
2013-04-24 22:30 ` TJ Luoma
2013-04-24 22:40 ` TJ Luoma [this message]
2013-04-25 1:29 ` Paul Hoffman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=F0BC3EAB-7C1F-47C6-93C5-E64C5A6501A0@gmail.com \
--to=luomat@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).