[GRASS-dev] running commands in background

Here is a question I’ve just run into as part of our agent modeling project.

I know that if you launch a command by only typing the command name (no arguments) followed by ‘&’, you can get the command gui to launch modally. Then this command can process while you launch another command.

Is there any way to get a command launched from the command line (i.e., with arguments) to run in the background so that you can launch another command from the command prompt?

I’ve tried…

[command] [arguments] &
r.what input=precip_9400 east_north=749204,3614262 &

and this doesn’t seem to work.

Michael


Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

I know that if you launch a command by only typing the command name
(no arguments) followed by Œ&¹, you can get the command gui to launch
modally. Then this command can process while you launch another
command.

Is there any way to get a command launched from the command line
(i.e., with arguments) to run in the background so that you can launch
another command from the command prompt?

I¹ve tried...

[command] [arguments] &
r.what input=precip_9400 east_north=749204,3614262 &

and this doesn¹t seem to work.

It proably did, just hit enter a bunch of times as the prompt is getting
clobbered by the first module's output? (redirect output?)

GRASS> g.command [arguments]
^Z
GRASS> bg

is another way.

Hamish

OK. I see now that it DOES work. The '&' give me back the prompt.

The thing that was confusing me is that pesky percent complete output that
keeps getting sent to the screen. Any way to shut that off?

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Hamish <hamish_nospam@yahoo.com>
Date: Thu, 25 May 2006 18:19:06 +1200
To: Michael Barton <michael.barton@asu.edu>
Cc: <grass-dev@grass.itc.it>
Subject: Re: [GRASS-dev] running commands in background

I know that if you launch a command by only typing the command name
(no arguments) followed by Œ&¹, you can get the command gui to launch
modally. Then this command can process while you launch another
command.

Is there any way to get a command launched from the command line
(i.e., with arguments) to run in the background so that you can launch
another command from the command prompt?

I¹ve tried...

[command] [arguments] &
r.what input=precip_9400 east_north=749204,3614262 &

and this doesn¹t seem to work.

It proably did, just hit enter a bunch of times as the prompt is getting
clobbered by the first module's output? (redirect output?)

GRASS> g.command [arguments]
^Z
GRASS> bg

is another way.

Hamish

Michael Barton wrote:

OK. I see now that it DOES work. The '&' give me back the prompt.

The thing that was confusing me is that pesky percent complete output that
keeps getting sent to the screen. Any way to shut that off?

No. There probably should be, though.

It would be simple enough to add an environment variable to disable
percent output altogether. It would be better to standardise this so
that it would disable all unnecessary output; the obvious approach
would be to have it disable G_message() as well, and migrate modules
to use G_message() instead of [f]printf().

--
Glynn Clements <glynn@gclements.plus.com>

I agree. I can think of instances where it would be useful to disable
unnecessary output on a particular file but not want to turn it off for all
of them. But this would entail adding a strict quiet flag to all. Maybe a
lot of work.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Glynn Clements <glynn@gclements.plus.com>
Date: Thu, 25 May 2006 21:46:55 +0100
To: Michael Barton <michael.barton@asu.edu>
Cc: <grass-dev@grass.itc.it>
Subject: Re: [GRASS-dev] running commands in background

Michael Barton wrote:

OK. I see now that it DOES work. The '&' give me back the prompt.

The thing that was confusing me is that pesky percent complete output that
keeps getting sent to the screen. Any way to shut that off?

No. There probably should be, though.

It would be simple enough to add an environment variable to disable
percent output altogether. It would be better to standardise this so
that it would disable all unnecessary output; the obvious approach
would be to have it disable G_message() as well, and migrate modules
to use G_message() instead of [f]printf().

--
Glynn Clements <glynn@gclements.plus.com>

>> OK. I see now that it DOES work. The '&' give me back the prompt.
>>
>> The thing that was confusing me is that pesky percent complete
>> output that keeps getting sent to the screen. Any way to shut that
>> off?
>
> No. There probably should be, though.
>
> It would be simple enough to add an environment variable to disable
> percent output altogether. It would be better to standardise this so
> that it would disable all unnecessary output; the obvious approach
> would be to have it disable G_message() as well, and migrate modules
> to use G_message() instead of [f]printf().

..

I agree. I can think of instances where it would be useful to disable
unnecessary output on a particular file but not want to turn it off
for all of them. But this would entail adding a strict quiet flag to
all. Maybe a lot of work.

Not much work, make G_message() and G_percent respect GRASS_QUIET=1 or
GRASS_VERBOSE=0 if they exist, then just set & unset the enviro variable
in the script as needed. WARNINGs and ERRORs should only be hidden by
the user with an explicit 2> /dev/null.

Hamish