2

I'm looking for a way to pass in the Raspberry Pi serial number to Chromium when running from the command line.

chromium-browser --incognito --noerrdialogs http://url.com?sn={serial}

Is this possible?

hunter
  • 123
  • 4

2 Answers2

3

2020-02-07 answer:
You can get the serial number with:

rpi ~$ cat /sys/firmware/devicetree/base/serial-number
10000000cd0297b1

So the command to call chromium on the command line with serial number resulted in:

rpi ~$ chromium-browser --incognito --noerrdialogs http://url.com?sn=$(cat /sys/firmware/devicetree/base/serial-number)
Ingo
  • 42,107
  • 20
  • 85
  • 197
  • 4 years later and I haven't thought about this in a while but this post has reinvigorated me. I will see how this works, thank you! – hunter Mar 26 '20 at 14:08
  • another question is if the serial number would be different on different rpi's that were clones of one another... – hunter Mar 26 '20 at 14:09
  • 1
    @hunter For my understanding the serial number is on the hardware, burned into a read only chip. You may have a clone of the operating system but not of the Raspberry Pi. – Ingo Mar 26 '20 at 14:26
2

here is a related question.

Briefly, you could read the file /proc/cpuinfo which would produce a listing like so

#cat /proc/cpuinfo

processor       : 0
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt                                                                                                                      vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 1
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt                                                                                                                      vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 2
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt                                                                                                                      vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 3
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt                                                                                                                      vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

Hardware        : BCM2709
Revision        : a02082
Serial          : 000000003d1d1c36

The last line should give you what you need.

you could use a

  • python script to read the serial number (as described in the link) and launch the chromium browser with the right argument using subprocess module (the linked question's answers have such examples)

  • if you commandline savvy awk would give you a one liner

Shreyas Murali
  • 2,416
  • 1
  • 15
  • 22
  • Does chromium offer any way to pull that variable and use it? – hunter Nov 21 '16 at 19:53
  • I doubt chromium would have such specialized functionality OOB. Moreover I'd think it would be a security problem the browser was able read arbitrary (system) files when requested by a page (via javascript). – Shreyas Murali Nov 21 '16 at 20:23