I am trying to write a script where it will cross check to things:
1.The architecture for which the setup file was intended (32 or 64 bit)
2.The Architecture of the system.
The second part is quite easy and can be figured out using commands like lscpu
and then extracting that specific line using combination of grep and awk
or sed
. However the first part is proving out to be a complicated one. I tried using the file command but it has a very irregular output. Hence it becomes very difficult extracting a specific column from it. I also tried using objdump
though traditionally not used for things like this. However as expected, due to its limitations, it does not recognize most of the file types.
The rest part of the script is dead simple where I would be comparing these values and proceeding with my intended tasks. I would like your help with the Point 1 mentioned above.
EDIT:
Adding few examples to explain my problem with file
command
$ file my_package_name.deb
my_package_name.deb: Debian binary package (format 2.0)
$ file my_package_name.rpm
my_package_name.rpm: RPM v3.0 bin i386/x86_64
Above examples were for setup files. If I were to run it for say some script, it would give me some things like:
$ file crclient O/P: crclient: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
As you guys can see, I am getting a very inconsistent output with file
command. Hence trying to extract a portion from this has become very complicated.