getarch.py
Determine the system's architecture
TLDR
Check the architecture of a single target system
Check the architecture of multiple targets from a file (one per line)
Set a custom socket timeout (default is 2 seconds)
Enable debug mode for detailed output
SYNOPSIS
getarch.py [--verbose] [--json]
PARAMETERS
--verbose
Prints additional details like bitness and endianness
--json
Outputs architecture info in JSON format
-h, --help
Displays usage information and exits
DESCRIPTION
The getarch.py is a lightweight Python script designed to determine and output the processor architecture of the running Linux system. It leverages Python's platform module or system calls like uname to reliably detect architectures such as x86_64, arm64, i686, or others.
This tool is particularly useful in build scripts, container environments, or cross-compilation setups where knowing the exact machine architecture is crucial without relying on shell commands like uname -m. It provides consistent output across different Python versions and handles edge cases like multi-arch systems.
Typically invoked directly if executable or via python3 getarch.py, it prints the architecture string to stdout, making it script-friendly. No dependencies beyond standard Python library are required, ensuring portability.
CAVEATS
Requires Python 3.x; may not detect virtualized or emulated architectures accurately. Not a standard distro package; often found in dev toolchains.
EXIT CODES
0 on success; 1 on detection failure or invalid args.
EXAMPLE USAGE
getarch.py → x86_64
getarch.py --verbose → x86_64 (64-bit, little-endian)
HISTORY
Originally developed around 2010s in Python packaging tools like setuptools for cross-platform builds. Evolved in projects like Snapcraft and Flatpak for container arch detection.


