backgroud task on demand?

backgroud task on demand?

Post by * Tong » Tue, 23 May 2000 04:00:00



Hi,

I'm wondering if I can do the following with sh shell script.

I know I can put a group of commands into background by specifying:

{ cmd1; cmd2; ... ; cmdn ; } &

Now the question is that how can I control whether to put the group of
commands in background by a variable. I.e, I wish I could do sth like
this:

 { cmd1; cmd2; ... ; cmdn ; } ${background_execution-'&'}

Sure the above is not working, but hope you get the idea -- control
whether the group of commands is executed in background by a single
variable. The point is that, if possible, I don't want to duplicate the
group into two branch of if/else clause.

Can I do that? thanks!

-- Tong
Anti-spam: remove underscore(s) to reply.
Welcome to my homepage http://members.xoom.com/suntong001/
  - All free contribution & collection
  - freeware &  music from the heavens

 
 
 

backgroud task on demand?

Post by Ken Pizzi » Wed, 24 May 2000 04:00:00



Quote:>Now the question is that how can I control whether to put the group of
>commands in background by a variable. I.e, I wish I could do sth like
>this:

> { cmd1; cmd2; ... ; cmdn ; } ${background_execution-'&'}

>Sure the above is not working, but hope you get the idea -- control
>whether the group of commands is executed in background by a single
>variable. The point is that, if possible, I don't want to duplicate the
>group into two branch of if/else clause.

Well, it's not precisely what you're asking for, but how about
the functionally similar:
 { cmd1; cmd2; ... ; cmdn ; } &
 case ${background_execution+set} in "") wait ;; esac
?

Or, if there is some subtlety which somehow makes that
inappropriate, how about:
  eval '{ cmd1; cmd2; ... ; cmdn ; } '${background_execution-&}
?

                --Ken Pizzini

 
 
 

backgroud task on demand?

Post by * Tong » Wed, 24 May 2000 04:00:00



> Well, it's not precisely what you're asking for, but how about

On the contrary, the 2 ways you suggested are exactly what I
was looking for. Thanks Ken, you have always been a great help!

-- Tong
Anti-spam: remove underscore(s) to reply.
Welcome to my homepage http://members.xoom.com/suntong001/
  - All free contribution & collection
  - freeware &  music from the heavens

 
 
 

1. Task States; can't kill 'D' tasks

Hi, I am new to Linux. I am using Slackware 2.3.0, and have successfully
installed it and am having a ball with disk sets A, AP and D. I had a
glitch the other day when searching tar archives looking for a specific
file. I would CTRL-C to quit searching when it was obvious that I was
looking at the wrong floppy. Then tar got hung up and froze, when I
flipped over to another console I noticed that the state of the task
reported by the top command indicated a 'D', which I learned as
"un-interruptable sleep". I could not kill this task, and bogged the system
down by consuming CPU time. Was I a contributor to this problem?

thanks, Bryan

2. Reading "." file

3. Ignoring tasks by task bar

4. EDC Fortran or MicroWay NDP Fortran run on Linux?

5. problem while putting task in task queue!!

6. cached memory is not in usual. Why?

7. converting Outlook tasks to StarOffice tasks?

8. MS vs. DOJ: Microsoft rendered .. irrelevant?

9. PPPD ON DEMAND : Fisrt demand is lost !

10. demand dialing vs. the other demand dialing

11. xterm backgroud?

12. HELP:Want to know when backgroud process ended

13. csh backgroud write problem