LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-16-2005, 10:48 PM   #1
bytebrowser
Member
 
Registered: Jun 2003
Location: QLD Australia
Distribution: Redhat 9.0 was but now like Fedora Core 2
Posts: 57

Rep: Reputation: 15
coding linux services


Hi

I am new to the coding side of linux. I am building a system that will require me to write a service (like httpd or vsftpd). I would just like to know where to start, what language(s) I need to learn and how to install the service.

I suppose I should also explain what I am trying to do! I am planning to build a system the can recieve an email (like postfix) and then extract information from that email and update a website using the attachment. I also need to build one that will listen for a request from the web, receive a file list and then move those files in the list from one folder to another.

Thanks heaps for your help!!

--pete
 
Old 01-16-2005, 11:23 PM   #2
Prabhat Sharda
LQ Newbie
 
Registered: Jan 2005
Location: Noida, India
Distribution: RedHat 9.0, CentOS 3.4
Posts: 17

Rep: Reputation: 0
hello dear,

Linux has a different way to run a program as service. No registry concept needed here. You have to make a script file, and put it in /etc/init.d/ directory, in which you have to run your program as a daemon.
As you may know, that daemon forks a new process and allows the parent to exit. Your parent here is the script file which you are running by service command, located at /etc/init.d/ directory.

Your script may use the functions of the 'function' file in /etc/init.d/ itself, in which you get daemon function, status function. Give the path of this file in your script.

If you see other files in /etc/init.d/ you will definitely get the basic idea behind that.
Kernel echos the message of the completion of your script, either [ OK ] or [FAILED]. You can easily judge from this, that whether your are on the right path or not. You can echo your own message too.

When the process successfully execute, it makes a pid file in /var/run/ directory, in which you have the process id of your process. When you see the status, kernel(may be your program too) checks for this file, extract the pid from the file, check for the process status and returns it. Similarly, if you call the service for stop, it checks for the pid in the respective .pid file, and kill that pid, and delete this file.

I think you can make your own shell scripts , follow all the processing by yourself. Always make a file (i think so)in /var/lock/sysconf/ directory whenever you start your service (if you are doing by your own script.) , and delete it whenever you are stopping your service.

Hope this will help you....
Good luck
 
Old 01-16-2005, 11:30 PM   #3
bytebrowser
Member
 
Registered: Jun 2003
Location: QLD Australia
Distribution: Redhat 9.0 was but now like Fedora Core 2
Posts: 57

Original Poster
Rep: Reputation: 15
Thanks for your response. It seems that it will be fairly difficult and different to do, seen as thou I am normally a Java and PL/SQL programmer!!
 
Old 01-16-2005, 11:50 PM   #4
Prabhat Sharda
LQ Newbie
 
Registered: Jan 2005
Location: Noida, India
Distribution: RedHat 9.0, CentOS 3.4
Posts: 17

Rep: Reputation: 0
no dear, its not too tough,
I think my way of explaining makes it so tough..

go to the /etc/init.d dir and see some files say smb, you will get the working behind that.

run ur program as daemon, you can save its pid by echo $! in respective .pid file in /var/run/ folder by yourself, and use touch command to make a file in /var/lock/sysconf dir.

for status you can use the status function in 'function' file.

for stop, you can use the function file here too. Remove the file in /var/lock/sysconf .

that's it..
yeah, you have to code some shell scripts for that or you can cheat this from other files defined in /etc/init.d/
 
Old 01-16-2005, 11:56 PM   #5
bytebrowser
Member
 
Registered: Jun 2003
Location: QLD Australia
Distribution: Redhat 9.0 was but now like Fedora Core 2
Posts: 57

Original Poster
Rep: Reputation: 15
Thanks again for you help
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need linux coding help iqbal Programming 1 07-21-2004 02:28 PM
Any links to very good Linux Coding Sites? Falelorn Programming 5 06-25-2004 05:02 PM
Linux coding type (hash) xtreme17 Linux - Security 7 11-03-2003 01:08 PM
Linux coding standard Sean Cleary Programming 5 08-22-2003 01:39 PM
I need information on a place to start coding C++ in Linux Manyguns Programming 1 06-06-2001 06:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration