I am extending snmpd with the extend directive to call some scripts for some OIDs. The script itself calls a custom helper program that gets extracts some value. The helper runs fine when it is started manually from the command line, but when I call it in the script it does not work because it cannot find our custom dependencies in /cots/boost-1.55/lib. I have added /cots/boost-1.55/lib to /etc/ld.conf.d/cots.conf and after running ldconfig verified that the boost libraries are in the cache. The script basically contains

result=`callHelper with arguments`
echo $result

and the result is captured by snmpd and returned. When I query the OID I get an error that it cannot find the external boost library.

I was able to make it work by calling su user in the script

result=`su user "callHelper with arguments"`
echo $result

Can anybody explain why the ld cache is correct when using su, but not when the script the program directly? I think it has something to do with the fact that snmpd is a system service and thus the environment is different, but ldconfig is not part of the environment.

  • restart snmpd from a shell which uses the new ld config. – Ipor Sircer Sep 13 '16 at 14:47
  • I did that. The configuration seems to be ignored completely. – Jens Sep 13 '16 at 15:14
  • then try a reboot – Ipor Sircer Sep 13 '16 at 15:20
  • also did that. ldconfig was done a long time ago. – Jens Sep 13 '16 at 15:32
  • worst case: result=LD_LIBRARY_PATH=/cots/boost-1.55/lib callHelper with arguments – Ipor Sircer Sep 13 '16 at 15:39

Have you check to see if your library is in your search PATH. Run the following in TERM to check your global PATH. Path is setup using .profile not config.

echo $PATH$ 

to see your search path. To explicitly add your library to your search path use the "set" command in Term. The dollar sign denotes that it is global call to the shell. Try

set PATH=$PATH$;/cots/boost-1.55/lib

The semicolon tells the shell to start a new search path. However, this only works if the search path exists. Of course it forks on my machine as with

set PATH=$PATH$;/cots/boost-1.55/lib
bash: /cots/boost-1.55/lib: -forks No such file or direc


  • Lee, delimiter for path is :, not ;. Path variable in shell should be defined as $PATH, not $PATH$ – Romeo Ninov Oct 12 '17 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.