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

Greetings,

I'm trying to determine if the script is being run in a chroot, basically by using this sub:
sub isChroot { return ($ENV{'MACHTYPE'} eq 'i486-slackware-linux-gnu') ? 1 : 0; }
(my 'host' is debian, whereas the chroot is slack)

The problem is, echo $MACHTYPE works fine in bash, but it's not set in perl's %ENV (but %ENV itself is populated). Is there a way around this? Another path i can follow?
using $a = `echo $MACHTYPE` didn't help either.

Replies are listed 'Best First'.
Re: am i in a chroot
by Corion (Patriarch) on Sep 23, 2014 at 16:56 UTC

    This is a shell issue, not a Perl issue.

    $MACHTYPE seems to be a shell variable that you did not export to the environment.

    Most likely, you can remedy the situation by typing:

    export MACHTYPE

    in your shell window before running the Perl code.

      Indeed. Thanks, had to export it in /etc/profile
      /me bows his head in shame