It's not a homework assignment.
It's a work assignment! I have been tasked with capturing the serial number and MAC address from Dell ChromeBooks. I have already developed a tool to do the same thing, but on Windows based computers via WinPE and VB scripts. I am just not familiar enough with Linux code to pull it off by myself. I can usually look at code and manipulate it to meet my needs. But I could not find anything that would work.
When all is said and done, I need a .csv file with Serial,MAC and a carriage return (or new line) after each entry. What I have done so far is this: Put the ChromeBook in developer mode, get to a shell prompt and log in as root. From there I mount a USB drive, run two commands that capture details about serial and MAC to a text file. That is where I am stuck. Now I need to put it all together and test it. I have played around with and coded in PHP, HTML, Javascript, Perl, MYSQL, VB, and a little C++. My goal here is to create a script and guide that an average tech could run on 1000's of ChromeBooks. Looking at Daniel's suggestion, I want to understand it. So let's break it down shall we....
awk '{if (substr($0,1,19)=="\"mlb_serial_number\"") print substr($0,22,7);
if (substr($0,1,21)=="encap:Ethernet HWaddr") print substr($0,23)}' \
$InFile >>$OutFile
I do not understand any of the numbers in (). Additionally, I only provided a snippet of the actual data in the text file that is created. I thought it would be easier. Basically I thought I would be able to find the text anywhere in the file and then print the next 7 characters after that text. Then put a comma, find the next string of data and print the next 17 characters after that, followed by a new line or carriage return. I am assuming $infile and $outfile are variables I would assign, but I don't see how the awk command gets the data from the original sample.txt file. The file names are irrelevant and was only used as an example. Below are the commands I am using to get to the point where I need assistance as well as the full contents of the text file I create in the process. I want to put steps 7-13 + the current question and then step 14 in a script. After 1-6 are done manually, the script would be ran and the rest would take care of itself. As far as the text file, I need service tag and MAC to be pulled out of the MAC.txt and placed in a new file as:
5DW3426,45:53:03:8a:63:74
Then put the USB in a different Chromebook and repeat the process. After the second time the new file should contain the exising and the new data:
5DW3426,45:53:03:8a:63:74
6DT3622,45:53:03:8a:62:39
1. Power on ChromeBook
2. Press Esc-Refresh+Power
3. At the recovery screen, press Ctrl-D
4. Press enter to turn off OS verification
5. press Ctrl-D to enter developer mode
6. Press Ctrl-Alt-F2 to enter command prompt
7. Type chronos
8. Type sudo bash
9. Type mount -t auto /dev/sdb1 /media/removable
10. Type dump_vpd_log --full --stdout > /media/removable/MAC.txt
11. Type ifconfig wlan0 >> /media/removable/MAC.txt
12. Type umount /dev/sdb1
13. Type eject /dev/sdb1
14. Type crossystem disable_dev_request=1; reboot
MAC.txt full contents:
"initial_locale"="en-US"
"initial_timezone"="America/Los_Angeles"
"keyboard_layout"="xkb:us::eng"
"model_name"="Dell Chromebook 11"
"region"="us"
"serial_number"="5DW3426"
"service_tag"="5DW3426"
"sku_number"="1"
"mlb_serial_number"="QDRMLK7021015248"
"gbind_attribute"="6b359deec451b36741ae43ba14a73690f44642be047aac4b7b47e0bab6a04c5933dd48c9"
"ubind_attribute"="687d337d15a685e8fcbcbcf9967afd25670046133a6d29727c79d195ba0925d76afa36ce"
"ActivateDate"="2014-07"
wlan0 Link encap:Ethernet HWaddr 45:53:03:8a:63:74
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)