Skip to content

Instantly share code, notes, and snippets.

@fourdollars
Created June 14, 2013 05:10
Show Gist options
  • Save fourdollars/5779590 to your computer and use it in GitHub Desktop.
Save fourdollars/5779590 to your computer and use it in GitHub Desktop.
A little script using busybox to extract all pci and usb modaliases strings and generate JSON request to some server.
#!/bin/busybox sh
JSON="$(echo '{"modalias":['; find /sys -name modalias -exec cat {} \; 2>/dev/null | grep -e '^\(pci\|usb\)' | sort | sed 's/^/"/' | sed 's/$/",/\'; busybox echo -n ']}')" # Find all pci/usb modaliases.
JSON="$(echo $JSON | sed 's/, ]}/]}/' | sed 's/\s\+//g')" # Remove trailing comma and white-space characters.
wget -q --header 'content-type: application/json' --post-data "$JSON" http://localhost:8000 -O -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment