Re: Can a Bourn Shell Script put itself in the background?

2009-06-06 Thread Martin McCormick
I really appreciate all the good suggestions I got from everybody who responded. Barry Byrne writes: I think the simplest thing would be to write a little wrapper script, that calls your other script. #!/bin/sh echo Stating Daemon Now /path/to/mainscript This got me to thinking

Re: Can a Bourn Shell Script put itself in the background?

2009-06-06 Thread Chris Rees
2009/6/6 Martin McCormick mar...@dc.cis.okstate.edu: This also works in Linux's /bin/sh which I believe is an alias for bash so occasionally little things work differently. Usually is, but in some it's linked to dash. https://wiki.ubuntu.com/DashAsBinSh Also, you should ONLY use

Re: Can a Bourn Shell Script put itself in the background?

2009-06-06 Thread Karl Vogel
Barry Byrne writes: B I think the simplest thing would be to write a little wrapper script B that calls your other script. B B #!/bin/sh B echo Stating Daemon Now B /path/to/mainscript You might be better off using daemon to make sure you're detached from the controlling terminal. Other

Re: Can a Bourn Shell Script put itself in the background?

2009-06-05 Thread Chad Perrin
On Thu, Jun 04, 2009 at 09:29:30AM -0700, Nerius Landys wrote: Just a thought, you can use the screen utility depending on what you are trying to do. For example if you want to start a job, long out of the machine completely, and then return to your job to see how it's running, you may choose

Re: Can a Bourn Shell Script put itself in the background?

2009-06-05 Thread relay.lists
= #!/bin/bash # This script will sleep # 50 times for 1 second in # the background main() { for ((i=0 ; i=50 ;i++)) do sleep 1 let i++ done } main # EOF == -- Best regards, Daniel

Re: Can a Bourn Shell Script put itself in the background?

2009-06-05 Thread Karl Vogel
On Fri, 5 Jun 2009 13:02:00 -0600, Chad Perrin per...@apotheon.com said: C I got the impression this question was about a script backgrounding itself, C though -- possibly creating a daemon using bash. Same here. This seems a bit slimy, but it works (assuming you don't already have an

Re: Can a Bourn Shell Script put itself in the background?

2009-06-05 Thread Polytropon
On Fri, 5 Jun 2009 13:02:00 -0600, Chad Perrin per...@apotheon.com wrote: . . . or use tmux instead of GNU Screen, if you like. I got the impression this question was about a script backgrounding itself, though -- possibly creating a daemon using bash. Maybe using detach (from ports) is a

Can a Bourn Shell Script put itself in the background?

2009-06-04 Thread Martin McCormick
I tried bg $$ but $$ is the current process invoked just as $! is the process of a backgrounded process started by that shell. So, can I make a shell script background itself after starting? Right now, I remind my coworkers to append the after the script name. the bg command expects

Re: Can a Bourn Shell Script put itself in the background?

2009-06-04 Thread Nikos Vassiliadis
Martin McCormick wrote: So, can I make a shell script background itself after starting? You could run all your code in a sub-shell: #!/bin/sh ( #your script here ) or in a shell function: old_script() { #your script here } old_script $* Perhaps the second way

RE: Can a Bourn Shell Script put itself in the background?

2009-06-04 Thread Barry Byrne
From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd-questi...@freebsd.org] On Behalf Of Martin McCormick I tried bg $$ but $$ is the current process invoked just as $! is the process of a backgrounded process started by that shell. So, can I make a shell script

Re: Can a Bourn Shell Script put itself in the background?

2009-06-04 Thread Nerius Landys
Just a thought, you can use the screen utility depending on what you are trying to do. For example if you want to start a job, long out of the machine completely, and then return to your job to see how it's running, you may choose to run screen. screen bash (Press Control-A then d) (Logout from