MAC vendor lookup: Difference between revisions

→‎{{header|UNIX Shell}}: Corrected quotes and added formatting. One-liners can be powerful, but not every shell script needs to be one. :) Added works-with tags and a pure-POSIX version.
(→‎{{header|AppleScript}}: Do the appending and delaying in AS instead of shell)
(→‎{{header|UNIX Shell}}: Corrected quotes and added formatting. One-liners can be powerful, but not every shell script needs to be one. :) Added works-with tags and a pure-POSIX version.)
Line 1,155:
=={{header|UNIX Shell}}==
{{trans|AppleScript}}
{{works with|Bourne Again SHell}}
Surprising that nobody had implemented the Bash / Shell version yet although the majority of the implementations on this page are just leveraging it.
{{works with|Korn Shell|93+}}
{{works with|Z Shell}}
Surprising that nobody had implemented the Bash / Shell version yet although the majority of the implementations on this page are just leveraging it.
<lang bash>macList=(88:53:2E:67:07:BE D4:F4:6F:C9:EF:8D FC:FB:FB:01:FA:21
4c:72:b9:56:fe:bc 00-14-22-01-23-45)
for burger in "${macList[@]}"; do
curl -s "http://api.macvendors.com/$burger" && echo
sleep 2
done</lang>
 
It can be made to work in a pure-POSIX shell without array variables:
{{works with|Bourne Shell}}
{{works with|Almquist Shell}}
<lang bash>set -- 88:53:2E:67:07:BE D4:F4:6F:C9:EF:8D FC:FB:FB:01:FA:21 \
4c:72:b9:56:fe:bc 00-14-22-01-23-45
for burger; do
curl -s "http://api.macvendors.com/$burger" && echo
sleep 2
done</lang>
 
The output is the same either way:
 
Shell one liners can be hard to read but are incredibly compact and powerful.
<lang bash>
macList=("88:53:2E:67:07:BE" "D4:F4:6F:C9:EF:8D" "FC:FB:FB:01:FA:21" "4c:72:b9:56:fe:bc" "00-14-22-01-23-45");for burger in ${macList[@]};do curl http://api.macvendors.com/$burger && sleep 5 && echo;done
</lang>
{{out}}
<pre>
1,480

edits