0

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.

John1024
  • 109,961
  • 14
  • 137
  • 171
theHeman
  • 505
  • 1
  • 6
  • 26
  • 2
    Could you give some example of the `file` command giving irregular output? Do you mean it gives irregular output between executable and non-executable files? – rahul Apr 14 '15 at 06:15
  • Here you go @rahul `$ file my_package_name.deb` O/P: `my_package_name.deb: Debian binary package (format 2.0)` `$ file my_package_name.rpm` O/P: `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` Apologies, the comment is not taking the break line formatting ! – theHeman Apr 14 '15 at 06:23
  • Duplicate http://stackoverflow.com/questions/106387/is-it-possible-to-detect-32-bit-vs-64-bit-in-a-bash-script – Nodak Apr 14 '15 at 06:58
  • 1
    @Nodak That question/solution does not address the first part of OPs question. I believe that is what the OP is looking for. – rahul Apr 14 '15 at 07:02
  • @ashhem I don't believe there is a simple/uniform way to do this across all types of files. I would suggest asking the question in the Unix and Linux site - unix.stackexchange.com. you are likely to find more options there. – rahul Apr 14 '15 at 07:05
  • @rahul, you're right. I assumed the *script* and the *setup file* were both creations of the same author. – Nodak Apr 14 '15 at 07:17
  • @Nodak sorry, but that is not what I really need. That part I have already figured it out. It's the first part m worried aboout :) – theHeman Apr 14 '15 at 09:45
  • @ashhem, I realise this now, as I was thrown by my assumption, because I know of no way to do this as both requirements, or failures, are either undefined or unknown, and not testable. – Nodak Apr 14 '15 at 11:34

0 Answers0