1

When I place this command in a perl script, it won't work:

`chkconfig --level 3 nslcd on`;

But if I execute it on a linux command shell, it works.

[root@barf Scripts]# chkconfig --level 3 nslcd on

I'm curious on why it does't work in a perl script.

TIA

  • 2
    Doesn't work is a strong statement. Does it sit on the couch all day? Does it want more money? Is it on Serverfault all the time? Please be specific! – Dennis Kaarsemaker Mar 27 '13 at 17:09
  • "Doesn't work" means the service did not start after a reboot. – usa ims Mar 27 '13 at 20:09
0

Does using

print `chkconfig --level 3 nslcd on`;

instead "fix" it? If yes, the answer is found here: https://stackoverflow.com/questions/799968/whats-the-difference-between-perls-backticks-system-and-exec

Backticks in Perl execute with a system() call, and their return value will be the STDOUT of the called command.

  • It didn't work (print chkconfig --level 3 nslcd on;) Maybe because a.pl calls b.pl which has the chkconfig --level 3 nslcd on in it? – usa ims Mar 27 '13 at 20:02
  • After your clarification on the question: Do you run the perl script with root permissions as well? – Squeezy Mar 28 '13 at 6:46
  • Yes, I do run the perl script with root permissions. – usa ims Mar 28 '13 at 14:35

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.