vk4tec

perl script mixed in with a service

Fri Apr 08, 2016 9:50 am

Hello

I have a service in /etc/init.d

I want to tag on a perl script to run in the "start" condition of a script

Like service dump1090 start

This starts up dump1090 plus the perl script. Do I just add the perl script in the start section of

/etc/init.d/dump1090?

I think u need sudo for "service" ?

Andrew

User avatar
solar3000
Posts: 1051
Joined: Sat May 18, 2013 12:14 am

Re: perl script mixed in with a service

Fri Apr 08, 2016 1:54 pm

just make the file executable and name it somefile.pl
it should run like any script.
Antikythera

User avatar
DougieLawson
Posts: 39297
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: perl script mixed in with a service

Sat Apr 09, 2016 12:42 pm

solar3000 wrote:just make the file executable and name it somefile.pl
it should run like any script.
The file name doesn't matter. somefile or somefile.pl or some.file.with.a.made-up.suffix.xyzzy will all execute in exactly the same way.

The crucial part of getting a perl program running is the shebang (#!) line at the top of the file and giving the file the executable permission bits.

Code: Select all

#!/usr/bin/perl
or

Code: Select all

#!/usr/bin/env perl
both work.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
DougieLawson
Posts: 39297
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: perl script mixed in with a service

Sat Apr 09, 2016 12:57 pm

vk4tec wrote: Do I just add the perl script in the start section of

/etc/init.d/dump1090?
1. Everything run as an init.d script runs as root until your program changes it. You don't need sudo.
2. The stuff in /etc/init.d/xxx is a bash script that gets your real program running as a service
3. Do NOT add your perl program in your /etc/init.d script, store your perl program in /usr/local/bin
4. With Raspbian Jessie and Ubuntu MATE stop using /etc/init.d, write a systemd service file and get that starting your service. It's a whole bunch easier that init.d anyway (once you've got your first service running).

https://www.digitalocean.com/community/ ... he-journal
https://www.digitalocean.com/community/ ... unit-files
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “General discussion”