1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Executing script on FreeBSD 6.0

Discussion in 'Installation and Maintenance of Ports or Packages' started by santino1984, Jan 7, 2011.

  1. santino1984

    santino1984 New Member

    Messages:
    6
    Likes Received:
    0
    Hello everyone,

    I have a problem to run a script on my FreeBSD 6.0 server. The script is in /usr/local/nagios/libexec/. It runs fine if I run into me in this directory. By cons, if I run it from another directory, it tells me it can not find the file utils.pm (found in /usr/local/nagios/libexec/ and he would therefore need). Now I need to run this script from another directory.

    I tried putting the absolute path, but it does nothing. I also added the directory /usr/local/nagios/libexec/ in the PATH, but nothing either There must be some subtleties with the BSD I do not know ...

    Thank you for your help!
     
  2. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,375
    Likes Received:
    3
    This has nothing to do with FreeBSD. It's a Perl script and should be treated as such. Setting the shell's PATH does absolutely nothing for the way Perl searches for it's modules.

    Perldoc: lib
     
  3. santino1984

    santino1984 New Member

    Messages:
    6
    Likes Received:
    0
    Thanks for your analyse. But what do you think I must do with perl? Script is an binary file, so ... For information, this script has no problem if I execute it from a Linux RedHat.
     
  4. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,375
    Likes Received:
    3
    Contradictio in terminus.

    A perl script is NOT a binary.
     
  5. santino1984

    santino1984 New Member

    Messages:
    6
    Likes Received:
    0
    Yes, sorry I have just read my mistake.
    It is a script, begin by :

    Code:
    !/usr/bin/perl -w
    If I type :

    Code:
    -bash-2.05b# which perl
    I have :

    Code:
    /usr/bin/perl
    If I type :

    Code:
    -bash-2.05b# /usr/bin/perl -v
    I have :

    Code:
    This is perl, v5.8.7 built for i386-freebsd-64int
    Is it wrong to run my script ?
     
  6. santino1984

    santino1984 New Member

    Messages:
    6
    Likes Received:
    0
    If I understand I must modify @INC variable ... but how ?
     
  7. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,375
    Likes Received:
    3
    There's nothing wrong. Read the perldoc link I posted.
     
  8. santino1984

    santino1984 New Member

    Messages:
    6
    Likes Received:
    0
    Yes, I have read, but I don't understand ...
    it doesn't matter
    Thanks
     
  9. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    11,178
    Likes Received:
    10
    Based on the perldoc link above, you need to modify the script. The "use lib" lets you add directories to the module search path. Does that help?
     
  10. santino1984

    santino1984 New Member

    Messages:
    6
    Likes Received:
    0
    Ok thanks to all !

    Adding this line in the script was ok :
    Code:
    use lib "/usr/local/nagios/libexec";
    
    Thanks again