David Ross
10/15/2004 1:08:00 PM
Okay, issue1. you shoulnt use direct paths. use
#!/usr/bin/env bash
this will find bash in the path and use that to execute
I dont understand why it wouldn't work.. something must be wrong with
the script?
I use all the BSDs.. you can use "su user - 'command' " because the
scripts are ran by root, so it automatically drops to the user and
executes the command when you run the commandspecified. You could also
have it built in to the program. Ruby has Process::Sys.setuid(integer)
which returns nil.
--dross
benny wrote:
>Dear list,
>
>I am using a kind of session-daemon who receives messages via drb and
>sometimes it has to execute shell commands based on the message and to
>return the result to the caller.
>
>now i got 2 problems:
>
>------------------
>1. problem
>
>Inside the session-daemon I used
>
> result = `#{cmd}`
>
>to execute the command and it worked quite well.
>however I wanted to get the error-messages as well, so I considered using
>Session::Bash:
>
> stdout, stderr = Session::Bash::new.execute "#{cmd}"
>
>for most command that works fine, but I have a shell script (first
>line /usr/local/bin/bash) which returns some messages using "echo".
>this messages never get into stdout (the new way) but the get back to result
>(the old way). I also tried "/usr/local/bin/bash myshellscript" but that
>didn't work ether. what am I missing?
>
>------------------------
>
>2nd problem (maybe only FreeBSD related)
>
>the normal way to automatically start a service on system start in FreeBSD
>is to have shell script in /usr/local/etc/rc.d/
>(say /usr/local/etc/rc.d/session_daemon_starter.sh) which respond to the
>parameter 'start' (and to 'stop' for the shutdown). I did this several
>time: no prob.
>
>the corresponding line in 'session_daemon_starter.sh' says
>
> path_to_my_session-daemon &
>
>to start it in the background. in 'path_to_my_session-daemon' itself the
>first line is
>
> #!/usr/local/bin/ruby
>
>as usual. when I start 'session_daemon_starter.sh' by hand, e.g.
>
> /usr/local/etc/rc.d/session_daemon_starter.sh start
>
>everything is working fine: the session-daemon is running, accepting
>messages via drb, sending messages via drb and sometimes executing
>shell-commands based on the messages it receives.
>
>when 'session_daemon_starter.sh' is automatically started with the system
>start the session-daemon is running, accepting messages via drb, sending
>messages via drb but doesn't execute any shell commands:
>neither via
> result = `#{cmd}`
>nor via
> stdout, stderr = Session::Bash::new.execute "#{cmd}"
>
>what am I missing?
>
>thank you for any response,
>
>benny
>
>
>
>
>