Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Running another program in daemon server

Reply
Thread Tools

Running another program in daemon server

 
 
janicehwang1325@yahoo.com
Guest
Posts: n/a
 
      06-22-2006
hi,

I came across a problem which is when i run the server program without
the daemon code, calling another program by `perl second.pl` is just
fine. However, when i put the server to be in daemon, calling to
another program by using `perl <something>.pl` is not working anymore.
What is the cause and how to solve?

Thank you very much.

 
Reply With Quote
 
 
 
 
Josef Moellers
Guest
Posts: n/a
 
      06-22-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> hi,
>
> I came across a problem which is when i run the server program without
> the daemon code, calling another program by `perl second.pl` is just
> fine. However, when i put the server to be in daemon, calling to
> another program by using `perl <something>.pl` is not working anymore.
> What is the cause and how to solve?
>
> Thank you very much.
>


Making a daemon occasionally involves changing the working directory
(from the Linux manpage of the daemon() function):

"Unless the argument nochdir is non-zero, daemon() changes the current
working directory to the root ("/")."

Check where you are.

--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett

 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      06-22-2006
(E-Mail Removed) wrote:

> I came across a problem which is when i run the server program without
> the daemon code, calling another program by `perl second.pl` is just
> fine. However, when i put the server to be in daemon, calling to
> another program by using `perl <something>.pl` is not working anymore.
> What is the cause and how to solve?


I would say:

`/path/to/perl /path/to/second.pl`;

or just

`/path/to/second.pl`;

But it's better to avoid backticks unless you need the output of the
external program. See

perldoc -f system

--
Bart

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      06-22-2006
"(E-Mail Removed)" <(E-Mail Removed)> wrote:
> hi,
>
> I came across a problem which is when i run the server program without
> the daemon code, calling another program by `perl second.pl` is just
> fine. However, when i put the server to be in daemon, calling to
> another program by using `perl <something>.pl` is not working anymore.
> What is the cause and how to solve?


If $? is nonzero, then the cause, or something resembling it, is in $!.


Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
janicehwang1325@yahoo.com
Guest
Posts: n/a
 
      06-23-2006
Thanks for all the information. It's true that i change the directory
to some other place when i run it as daemon. thank you very much.



(E-Mail Removed) wrote:
> hi,
>
> I came across a problem which is when i run the server program without
> the daemon code, calling another program by `perl second.pl` is just
> fine. However, when i put the server to be in daemon, calling to
> another program by using `perl <something>.pl` is not working anymore.
> What is the cause and how to solve?
>
> Thank you very much.


 
Reply With Quote
 
janicehwang1325@yahoo.com
Guest
Posts: n/a
 
      06-23-2006
The directory is changed to the root directory. However, i try to run
another program using `\path\to\perl \path\to\client.pl` still doesn't
work. is there any other solutions?


Josef Moellers wrote:
> (E-Mail Removed) wrote:
> > hi,
> >
> > I came across a problem which is when i run the server program without
> > the daemon code, calling another program by `perl second.pl` is just
> > fine. However, when i put the server to be in daemon, calling to
> > another program by using `perl <something>.pl` is not working anymore.
> > What is the cause and how to solve?
> >
> > Thank you very much.
> >

>
> Making a daemon occasionally involves changing the working directory
> (from the Linux manpage of the daemon() function):
>
> "Unless the argument nochdir is non-zero, daemon() changes the current
> working directory to the root ("/")."
>
> Check where you are.
>
> --
> Josef Möllers (Pinguinpfleger bei FSC)
> If failure had no penalty success would not be a prize
> -- T. Pratchett


 
Reply With Quote
 
janicehwang1325@yahoo.com
Guest
Posts: n/a
 
      06-23-2006
Hi,

Just to share with you, my problem is solved by just putting the
program in root directory. It might not be the best solution however,
it did solve my current headache. Anyhow, if there is another way to
solve it, please share with me. Thank you!


Josef Moellers wrote:
> (E-Mail Removed) wrote:
> > hi,
> >
> > I came across a problem which is when i run the server program without
> > the daemon code, calling another program by `perl second.pl` is just
> > fine. However, when i put the server to be in daemon, calling to
> > another program by using `perl <something>.pl` is not working anymore.
> > What is the cause and how to solve?
> >
> > Thank you very much.
> >

>
> Making a daemon occasionally involves changing the working directory
> (from the Linux manpage of the daemon() function):
>
> "Unless the argument nochdir is non-zero, daemon() changes the current
> working directory to the root ("/")."
>
> Check where you are.
>
> --
> Josef Möllers (Pinguinpfleger bei FSC)
> If failure had no penalty success would not be a prize
> -- T. Pratchett


 
Reply With Quote
 
Ted Zlatanov
Guest
Posts: n/a
 
      06-23-2006
On 22 Jun 2006, (E-Mail Removed) wrote:

> The directory is changed to the root directory. However, i try to run
> another program using `\path\to\perl \path\to\client.pl` still doesn't
> work. is there any other solutions?


You may be specifying the path as "\path\to\perl" which won't work.
You need to either use "\\path\\to\\perl" or '\path\to\perl' (single
quotes) or "/path/to/perl".

(ditto for the path to the client)

Generally specify paths for system() with '/' instead of '\' and life
will be easier and more portable.

Ted
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      06-23-2006
Ted Zlatanov <(E-Mail Removed)> wrote:

> Generally specify paths for system() with '/' instead of '\' and life
> will be easier and more portable.



But only for the more-than-1-arg form of system().

You cannot use forward slashes with 1-arg system() on
silly "operating systems". (I think.)


--
Tad McClellan SGML consulting
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      06-23-2006

Quoth (E-Mail Removed):
> Ted Zlatanov <(E-Mail Removed)> wrote:
>
> > Generally specify paths for system() with '/' instead of '\' and life
> > will be easier and more portable.

>
> But only for the more-than-1-arg form of system().
>
> You cannot use forward slashes with 1-arg system() on
> silly "operating systems". (I think.)


....unless you change your shell.

Ben

--
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon) Floris Bruynooghe Python 1 03-24-2009 02:58 PM
Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon) Jean-Paul Calderone Python 0 03-20-2009 01:02 PM
Daemon Win32::Daemon; ph1975@gmail.com Perl Misc 0 09-07-2006 10:58 AM
Help !I want to write a program to count the running time of another program freehomesp@yahoo.com.cn C Programming 1 08-12-2005 06:13 AM
running java program as daemon on Unix System Fatih Java 4 04-09-2004 09:40 AM



Advertisments