sriharsha has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am facing a problem with execution of a system command on Linux. As part of our product, we are shipping perl 5.8.8 v5.8.8 built for i686-linux. Now, i'm trying to execute, `uname -m` via perl script on i686- 32 bit linux machines, x86_64 linux machines and ia64 linux machines. The output i am getting for that command executed, is correct for i686 and x86_64, however it is wrong for ia64 machines. `uname -m` on a ia64 bit machine using the perl that we ship, gives the output as, "i686" in place of "ia64". I am thinking, if this could be a problem with the distributions of perl for various architectures. I don't have a solution on resolving this. I may even have to ship a new version of perl for ia64 machine. Is there anyway i can make the existing shipped perl do the job of getting the right output..??
  • Comment on Perl Distribution differences for i686/x86_64 and ia64 over Linux.

Replies are listed 'Best First'.
Re: Perl Distribution differences for i686/x86_64 and ia64 over Linux.
by cjb (Friar) on Apr 12, 2011 at 12:07 UTC
    If you're running `uname -m` in backticks you're just getting the output of the uname command on the host OS, so not a Perl Issue. You could try POSIX::uname and see if you get anything more useful.

      This, too, was a good call. I put the emulator directory at the start of my search path, just to make sure POSIX wasn't using the system uname to determine its output, then ran a quick debugging session.

      PATH=/emul/ia32-linux/bin:$PATH perl -de 0 Loading DB routines from perl5db.pl version 1.3 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 0 DB<1> use POSIX DB<2> x POSIX::uname 0 'Linux' 1 'frodo' 2 '2.6.16.60-0.60.1-default' 3 '#1 SMP Tue Mar 9 09:44:12 UTC 2010' 4 'ia64'

        POSIX::uname() does not call the external uname(1) program but the uname(2) syscall that, depending on the instruction set for which the running program was compiled, returns ia64 or i686.

        So, calling POSIX::uname() is not going to solve the OP problem.

Re: Perl Distribution differences for i686/x86_64 and ia64 over Linux.
by salva (Canon) on Apr 12, 2011 at 12:30 UTC
    ia64 Linux run x86 code in an emulated 32bits environment. Your script is probably launching a 32bit version of uname. Try...
    `/bin/uname -m`

      Good call!

      /emul/ia32-linux/bin/uname -m i686
      That nicely explains what the OP observed.

Re: Perl Distribution differences for i686/x86_64 and ia64 over Linux.
by jpl (Monk) on Apr 12, 2011 at 12:36 UTC

    To further muddy the waters, on the only ia64 system I have access to

    uname -m ia64
    I was hoping some other uname option would yield what you were seeing, but it's ia64 everywhere. I can't offer a useful explanation of what you are seeing.

Re: Perl Distribution differences for i686/x86_64 and ia64 over Linux.
by jpl (Monk) on Apr 12, 2011 at 13:52 UTC

    A (one hopes) final observation by me. On my ia64 system, /emul/ia32-linux/bin contains sh and bash as well as uname. So if you are using system() or backticks elsewhere in your perl scripts, you may get results that differ from what you might expect. It would be good to understand why you got the emulated version of uname to begin with, and try to correct that.