Running another program in daemon server

Discussion in 'Perl Misc' started by janicehwang1325@yahoo.com, Jun 22, 2006.

  1. Guest

    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.
     
    , Jun 22, 2006
    #1
    1. Advertising

  2. 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
     
    Josef Moellers, Jun 22, 2006
    #2
    1. Advertising

  3. 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
     
    Bart Van der Donck, Jun 22, 2006
    #3
  4. Guest

    "" <> 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
     
    , Jun 22, 2006
    #4
  5. Guest

    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.



    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.
     
    , Jun 23, 2006
    #5
  6. Guest

    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:
    > 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
     
    , Jun 23, 2006
    #6
  7. Guest

    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:
    > 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
     
    , Jun 23, 2006
    #7
  8. Ted Zlatanov Guest

    On 22 Jun 2006, 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
     
    Ted Zlatanov, Jun 23, 2006
    #8
  9. Ted Zlatanov <> 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
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jun 23, 2006
    #9
  10. Ben Morrow Guest

    Quoth :
    > Ted Zlatanov <> 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.'
     
    Ben Morrow, Jun 23, 2006
    #10
  11. Guest

    I will try based on your advice. thank you very much.


    Ben Morrow wrote:
    > Quoth :
    > > Ted Zlatanov <> 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.'
    >
     
    , Jun 26, 2006
    #11
  12. Ted Zlatanov Guest

    On 23 Jun 2006, wrote:

    Ted Zlatanov <> 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.)


    Yes, unfortunately that's passed to the command interpreter which will
    do violent things to that purty command line. I try very hard to use
    the multi-arg system() call to avoid problems like this (and security
    problems!). Thanks for catching that.

    Ted
     
    Ted Zlatanov, Jun 27, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fatih
    Replies:
    4
    Views:
    14,003
    Fatih
    Apr 9, 2004
  2. Replies:
    1
    Views:
    492
    Walter Roberson
    Aug 12, 2005
  3. Jean-Paul Calderone
    Replies:
    0
    Views:
    477
    Jean-Paul Calderone
    Mar 20, 2009
  4. Floris Bruynooghe
    Replies:
    1
    Views:
    472
    Floris Bruynooghe
    Mar 24, 2009
  5. Daemon Win32::Daemon;

    , Sep 7, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    274
Loading...

Share This Page