# Executing script on FreeBSD 6.0



## santino1984 (Jan 7, 2011)

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!


----------



## SirDice (Jan 7, 2011)

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


----------



## santino1984 (Jan 7, 2011)

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.


----------



## SirDice (Jan 7, 2011)

santino1984 said:
			
		

> Script is an binary file, so ...


Contradictio in terminus.

A perl script is NOT a binary.


----------



## santino1984 (Jan 7, 2011)

Yes, sorry I have just read my mistake.
It is a script, begin by :


```
!/usr/bin/perl -w
```

If I type :


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


```
/usr/bin/perl
```

If I type :


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


```
This is perl, v5.8.7 built for i386-freebsd-64int
```

Is it wrong to run my script ?


----------



## santino1984 (Jan 7, 2011)

If I understand I must modify @INC variable ... but how ?


----------



## SirDice (Jan 7, 2011)

There's nothing wrong. Read the perldoc link I posted.


----------



## santino1984 (Jan 7, 2011)

Yes, I have read, but I don't understand ... 
it doesn't matter
Thanks


----------



## wblock@ (Jan 7, 2011)

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?


----------



## santino1984 (Jan 10, 2011)

Ok thanks to all ! 

Adding this line in the script was ok :

```
use lib "/usr/local/nagios/libexec";
```
Thanks again


----------

