0

I am working through this tutorial on daemonizing php scripts. When I run the following Unix command:

. /etc/init.d/functions

#startup values
log=/var/log/Daemon.log

#verify that the executable exists
test -x /home/godlikemouse/Daemon.php || exit 0RETVAL=0

prog="Daemon"
proc=/var/lock/subsys/Daemon
bin=/home/godlikemouse/Daemon.php

start() {
    # Check if Daemon is already running
    if [ ! -f $proc ]; then
        echo -n $"Starting $prog: "
        daemon $bin --log=$log
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch $proc
        echo
    fi

    return $RETVAL
}

I get the following output:

./Daemon: line 12: /etc/init.d/functions: No such file or directory
Starting Daemon: daemon: unrecognized option `--log=/var/log/Daemon.log'

I looked at my file system and there was no /etc/init.d file. Can anyone tell me what this is and where to obtain it? Also is the absence of that file what's causing the other error?

Ben Pearce
  • 6,884
  • 18
  • 70
  • 127
  • `/etc/init.d/` is a directory in UNIX systems. Could you indicate which is line #12? – fedorqui May 29 '13 at 22:27
  • Oh yes. Line 12 is the one refering to the directory ./etc/init.d/function – Ben Pearce May 29 '13 at 22:29
  • I guess you are following the issue http://stackoverflow.com/questions/16810875/getting-command-not-found-when-running-daemon-in-unix . The web you indicate there talks about installing in a CentOS. Having a Macintosh, what about installing a virtualization program like Virtual Box? So from your Macintosh you can work in another SO. – fedorqui May 29 '13 at 22:32
  • What does SO stand for? – Ben Pearce May 29 '13 at 22:36
  • Sorry, I thought in catalan where we say "SO". I meant OS - Operating System. – fedorqui May 29 '13 at 22:38
  • I love Barcelona! Anyway that seems like a pretty drastic solution. Do you think there's anyway to get these files on OSX. – Ben Pearce May 29 '13 at 22:44
  • Nice :)) I am not familiar with Macintosh so cannot really tell you. I just found http://serverfault.com/questions/10564/setting-up-daemons-on-mac-os-x that my help you. Make some tests, etc, and for sure you will make it! – fedorqui May 29 '13 at 22:50

1 Answers1

1

Separate your args within their own " " double-quotes:

args="--node $prog"
daemon "nohup ${exe}" "$args &" </dev/null 2>/dev/null
daemon "exe" "args"
Alessandro
  • 742
  • 1
  • 10
  • 34
SJ Martin
  • 11
  • 1