1

I ran into a problem that I've never seen before and can't exactly explain. I was helping someone run a perl based install on a RedHad 4.6 zLinux and running under sudo seemed to grab the system perl rather than the fully qualified perl executable.

Example:

/my/perl/bin> ./perl -v == 5.8.8
/my/perl/bin> /my/perl/bin/perl -v == 5.8.8
/my/perl/bin> sudo /my/perl/bin/perl -v == 5.8.5????

Even though we were fully qualifying the path to our perl it was still grabbing /usr/bin/perl when running under sudo. I have no idea why, any gurus know?

raven
  • 18,004
  • 16
  • 81
  • 112

3 Answers3

0

check if your sudoers file has the the secure_path option set if so then that is your PATH

Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

crubio
  • 1
0

preserve environment:

sudo -E /my/perl/bin/perl -v
Michał Šrajer
  • 30,364
  • 7
  • 62
  • 85
0

Edit you sudoers config :

sudo gedit /etc/sudoers

add this line

Defaults env_keep +=PATH

this is similar to sudo -Ebut persistent.

Ahmed Aswani
  • 8,271
  • 7
  • 33
  • 54