Is there a way through command line to know what keyboard physical layout a macbook has? I cannot find that specific information in system_profiler. I want to know if the computer has a US, UK, ES, etc keyboard layout.
The aim is to script it, upload it to my MDM so I can run it in all the company's laptops and find out that information.
Thanks!
running the terminal command system_profiler SPSPIDataType
it shows this:
SPI:
Apple Internal Keyboard / Trackpad:
Product ID: 0x0278
Vendor ID: 0x05ac (Apple Inc.)
ST Version: 8.96
MT Version: 4.69
Serial Number: FM7741701QVGN41A5+RNZ
Manufacturer: Apple Inc.
Location ID: 0x01000000
I run it in two different macbooks, one UK, one ES. I was hoping that the Location ID would show something different but that was not the case.
If I do this in Terminal:
defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | egrep -w 'KeyboardLayout Name'
I get this:
"KeyboardLayout Name" = *name of my keyboard in readable form*
I think I just found the solution, like this:
ioreg -l | grep KeyboardLanguage | awk '{print substr( $0, 56, 20)}' | tr -d "\" =|"
Thanks,
Federico.
Related
In Windows 10, I am using qrencode for printing QR codes to image files. The printing is successful but I am stuck at adding line breaks. I have tried the below method with no success in line breaks.
Windows Command Prompt:
d:\ qrencode -o qrcode.png "INDO GERMAN ALKALOIDS \nUnique ID: ABC-123456789 \nAPI-Name: ABCDEFGH \nBrand: Indo-101 \nAddress: Inga House, Mahakali Road, Andheri-East, Mumbai-400093, \nTel-022-28202932/33, \nMobile: 9833942075, \nBatch No.: XYZ888999000, \nBatch Size: 1020, \nMfgd.Date: 29-12-2022, \nExpiry Date: 31-12-2023, \nContainer Code: RRR-101020, \nMfgr Lic.No.: ------------, \nStorage Instruction: Store in cool area 20deg"
After playing around for some time, I came across the below command in the Ubuntu Manuals:
cat bigfile.txt | qrencode -S -v 40 -l L -o output.png
I placed the required content as below in a text file named qr-data.txt
INDO GERMAN ALKALOIDS
Unique ID: ABC-123456789
API-Name: ABCDEFGH
Brand: Indo-101
Then at the DOS prompt I typed:
type qr-data.txt | qrencode -o qr-code.png
It now works perfect for me.
Note that I used [type] instead of [cat] in MS DOS.
Is there capacity within amazon/centos/linux to switch the ordering round of nitro disks?
I have an ami which consistently has devices in the incorrect order, by this I mean nvme1n1 and nvme2n1 should be switched round. If I run nvme id-ctrl -v /dev/nvme1n1 | grep sn I get a different serial number back following a reboot. I know they're "wrong" as the serial numbers are not reflective of their capacity... Hope that makes sense (I appreciate it's a bit confusing). This only ever occurs on servers with two or more disks; upon a reboot the disks are "correct"
My question is, is there a method of forcing the nvme device to disconnect and reconnect (in the hope that the mapping works as expected in the correct order).
Thanks guys
Amazon Linux version 2017.09.01 and later contains scripts and a udev rule that automatically maps NVMe devices to /dev/xvd?. It is very briefly mentioned in the documentation, but there is not much information there.
You can obtain a copy by launching the Amazon Linux AMI, but there are also other places on the web where they have been posted. For example, I found this gist.
Very simple in the end:
echo 1 > /sys/bus/pci/devices/$(readlink -f /sys/class/nvme/nvme1 | awk -F "/" '{print $5}')/remove
echo 1 > /sys/bus/pci/devices/$(readlink -f /sys/class/nvme/nvme2 | awk -F "/" '{print $5}')/remove
echo 1 > /sys/bus/pci/rescan
On Linux I can get UUID are stored in some files on system (in example /var/lib/dbus/machine-id, /proc/sys/kernel/random/uuid, /proc/sys/kernel/random/boot_id), can I find similar files on OS X?
You can use uuidgen:
/usr/bin/uuidgen
$ uuidgen
6A786B80-8D52-4344-93D1-37C95F6C803A
Your question seems somewhat confused...
If you want to generate a unique UUID for some reason, use #ergonaut's answer:
uuidgen
70095BA9-B866-42F2-9DE4-606F54EBBA88
If you want to get a unique identifier for a particular CPU/machine, you can use the system_profiler like this:
system_profiler SPHardwareDataType
Output
Hardware:
Hardware Overview:
Model Name: iMac
Model Identifier: iMac12,2
Processor Name: Intel Core i7
Processor Speed: 3.4 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 8 MB
Memory: 16 GB
Boot ROM Version: IM121.0047.B21
SMC Version (system): 1.72f2
Serial Number (system): DGKH80PXDHJW
Hardware UUID: 1025AC04-9F9E-5342-9EF4-206EBAE40BF6
Or, if you want to select one of those values specifically, you can use:
system_profiler SPHardwareDataType | awk '/UUID/ { print $3; }'
1025AC04-9F9E-5342-9EF4-206EBAE40BF6
Or, you can use the MAC address of your primary Ethernet interface like this:
ifconfig en0 | awk '/ether/{print $2}'
3c:07:54:76:38:cd
I'd need to take the output from a show mac address-table on a Cisco switch and extract only the Mac addresses and put them in a CSV file.
The output looks like this
vlan Mac Address Type Ports
----- ----------- ----- -----
All 0011.2233.4455 STATIC CPU
All 0011.2233.4466 STATIC CPU
All 0011.2233.4477 STATIC CPU
All 0011.2233.4488 STATIC CPU
Macs are displayed in groups of 4 as seen above. I need to grab each MAC address and output it to a csv file.
This works but it also grabs unwanted output.
awk '{print $2}' macTable.log > macTable.csv
Just add a condition that the field only contains digits and dots:
awk '$2~/^[0-9.]+$/{print $2}' macTable.log
You can test for the two types of mac-address STATIC and DYNAMIC
awk 'tolower($3)~/static|dynamic/ {print $2}' log
0011.2233.4455
0011.2233.4466
0011.2233.4477
0011.2233.4488
PS you need to use tolower since switch may use uppercase and routers uses lowercase.
You could also do it with grep:
egrep -o '([0-9]{4}\.){2}[0-9]{4}'
Output:
0011.2233.4455
0011.2233.4466
0011.2233.4477
0011.2233.4488
My problem is that when I add a printer using the Printers and Scanners UI printing works, when I add the same printer using lpadmin it doesn't.
To Add it through the UI I did the following:
From Printers and Scanners I selected the IP tab.
Address: 10.20.30.40, Protocol HP Jetdirect - Socket, Queue left blank, Name: TEST_01, Location "Top Floor", Use -> Select software -> HP LaserJet P3010 Series
After doing this, the Printer works as expected.
This is a (segment from a) script containing my lpadmin command that doesn't work
SUBNET=socket://10.20.30.
TEST_01=40
PPD_DIR=/Library/Printers/PPDs/Contents/Resources
TEST_01_PPD="hp LaserJet P3010 Series.gz"
lpadmin -E -p TEST_01 -v $SUBNET$TEST_01 -P "$PPD_DIR/$TEST_01_PPD" -D "TEST_01" -L "Top Floor"
The printer appears correctly in the UI but shows as paused.
I did find a message in system.log that may or may not be relevant - I was using Notes to test the printer:
Notes[502]: Failed to connect (_delegate) outlet from (com_hp_psdriver_19_11_0_PDEView) to (com_hp_psdriver_19_11_0_PDEAccountingController): missing setter or instance variable
Notes[2198]: Printing failed because PMSessionEndDocumentNoDialog() returned -30871.
The reason I want to use a script is that there are 20 printers to add on each of 30 new Macs. The actual script uses a series of arrays with lpadmin in a for loop. Everything I have read says it should work. What am I missing?
I think -E specified before the printer name enables encryption, whereas specified after it Enables the printer - effectively "unpausing" it. Madness- I know!
Mad Apple Documentation - see second sentence
I think you want:
lpadmin -p TEST_01 -v $SUBNET$TEST_01 -P "$PPD_DIR/$TEST_01_PPD" -D "TEST_01" -L "Top Floor" -E
I don't have a direct answer, but I can suggest an alternate approach: set up all 20 printers by hand on one computer, then copy the /etc/cups directory from that one to the other 29.