MAC vendor lookup: Difference between revisions
Content added Content deleted
(→{{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: | Line 1,155: | ||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
{{trans|AppleScript}} |
{{trans|AppleScript}} |
||
{{works with|Bourne Again SHell}} |
|||
⚫ | |||
{{works with|Korn Shell|93+}} |
|||
{{works with|Z Shell}} |
|||
⚫ | |||
<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 |
|||
⚫ | |||
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 |
|||
⚫ | |||
{{out}} |
{{out}} |
||
<pre> |
<pre> |