Convert a MAC Address to Motorola S-Records
If you do embedded programming you're probably familiar with Motorola S-Records. This following script takes a MAC Address and outputs S-Record data.
Given a MAC Address the script outputs S-Record data:
# sh macid.sh 00:11:22:33:44:55 S00D0000333737382D322E746D703B S1090000001122334455F7 S9030000FCOptionally, you can specify an address for re-basing the S-Record data and an output file name to write the S-Records to:
# sh macid.sh --address 0xffff0000 --output ma 00:11:22:33:44:55 # cat ma S00D0000333733302D322E746D7047 S30BFFFF0000001122334455F7 S705FFFF0000FCThe script follows:
#!/bin/bash
mac_addr_pattern='^[0-9a-fA-F]{2}[-:]'
mac_addr_pattern+='[0-9a-fA-F]{2}[-:]'
mac_addr_pattern+='[0-9a-fA-F]{2}[-:]'
mac_addr_pattern+='[0-9a-fA-F]{2}[-:]'
mac_addr_pattern+='[0-9a-fA-F]{2}[-:]'
mac_addr_pattern+='[0-9a-fA-F]{2}'
address_pattern='^(0x)?[0-9a-fA-F]{8}$'
######################################################################
function usage()
{
if [[ "$*" ]]; then echo $* >&2; fi
cat >&2 <<EOU
Usage: $0 OPTIONS MAC-ADDRESS
--address ADDRESS Address in FLASH of serial number or MAC Id.
--output FILE Output file.
EOU
exit 1
}
######################################################################
trap "rm -f $$-?.tmp" EXIT
output_file=
while [[ "$1" ]]
do
case "$1" in
--address)
shift
if [[ ! "$1" ]]; then usage "Missing address"; fi
address=$1
if ! grep --silent -P "$address_pattern" <<<$address; then
usage "Invalid address: $address"
fi
;;
--output)
shift
if [[ ! "$1" ]]; then usage "Missing output file name"; fi
output_file=$1
;;
*)
mac_addr=$1
shift
if [[ "$1" ]]; then usage "Unexpected argument: $1"; fi
if ! grep --silent -P "$mac_addr_pattern" <<<$mac_addr; then
usage "Invalid mac address: $mac_addr"
fi
;;
esac
shift
done
if [[ ! "$mac_addr" ]]; then usage "Missing mac address"; fi
mac_addr=${mac_addr/:/ }
mac_addr=${mac_addr/-/ }
echo "0000: $mac_addr" | xxd -r >$$-1.tmp
opt=
if [[ "$address" ]]; then opt="--change-addresses $address"; fi
objcopy $opt -I binary -O srec $$-1.tmp $$-2.tmp
if [[ "$output_file" ]]; then
mv $$-2.tmp $output_file
else
cat $$-2.tmp
fi
# vim: tabstop=4: shiftwidth=4: noexpandtab:
# kate: tab-width 4; indent-width 4; replace-tabs false;
Mitch Frazier is an Associate Editor for Linux Journal.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- New Products
- RSS Feeds
- Tech Tip: Really Simple HTTP Server with Python
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.



1 hour 20 min ago
2 hours 29 min ago
3 hours 15 min ago
3 hours 37 min ago
9 hours 51 min ago
15 hours 30 min ago
21 hours 29 min ago
21 hours 52 min ago
22 hours 2 min ago
22 hours 6 min ago