[GRASS-user] Stopping/killing a "puased" command

Hi,

I am trying to combine a commandline tool (MarZone) with GRASS in a shell script (MSYS in OSGeo4W or Ubuntu).

The MarZone command should run in a loop where it recives new input from GRASS in each iteration.

My scripts works in principle, however, unlike other command line tools, MarZone does not end when it is done, but one has to press enter to stop.

It ends with “Press return to exit.” on screen.

In order to handle this in a loop, I simply kill the process after the time I expect the sofware to run (plus a little time buffer):

Like this:

perl -e ‘alarm shift @ARGV; exec @ARGV’ 60 ./MarZone_x64.exe

Unfortunately, this is neither an effient nor a stable solution as the time the software runs can vary quite a bit, depending on some parameter settings.

My question is, is there a way to somehow catch, that the software is ready (when it prints “Press return to exit.”), an kill it then?

Any idea?

Thanks for helping,

Stefan

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Stefan,

can you pipe the MarZone output into a tmp file, check that file in
regular intervals for the desired string and stop the process if the
string is found. Not the most beautiful way I can think of but maybe
an option ..

Cheers,

Stefan

On 10/30/2014 09:06 AM, Blumentrath, Stefan wrote:

Hi,

I am trying to combine a commandline tool (MarZone) with GRASS in a
shell script (MSYS in OSGeo4W or Ubuntu).

The MarZone command should run in a loop where it recives new input
from GRASS in each iteration.

My scripts works in principle, however, unlike other command line
tools, MarZone does not end when it is done, but one has to press
enter to stop.

It ends with "Press return to exit." on screen.

In order to handle this in a loop, I simply kill the process after
the time I expect the sofware to run (plus a little time buffer):

Like this:

perl -e 'alarm shift @ARGV; exec @ARGV' 60 ./MarZone_x64.exe

Unfortunately, this is neither an effient nor a stable solution as
the time the software runs can vary quite a bit, depending on some
parameter settings.

My question is, is there a way to somehow catch, that the software
is ready (when it prints "Press return to exit."), an kill it
then?

Any idea?

Thanks for helping,

Stefan

_______________________________________________ grass-user mailing
list grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

- --
Stefan Lüdtke

Section 5.4- Hydrology
Tel.: +49 331 288 2821
Fax: +49 331 288 1570
Email: sluedtke@gfz-potsdam.de

Helmholtz-Zentrum Potsdam
Deutsches GeoForschungsZentrum GFZ
(GFZ German Research Centre for Geoscience)
Stiftung des öff. Rechts Land Brandenburg
Telegrafenberg, 14473 Potsdam
- -------------------

PGP Public Key: http://bit.ly/13d9Sca
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJUUfSTAAoJEB5GAbKcg+D8SLAH/1gAW/aMmCP4Ac3qgQFKQVBY
CK8OKH/I9ZAFUuG16uBj/fOZ2agm8N3Sz6xjZV9NDPk4pPz2PK3U2OTDT7DH8zeM
cvSJnETrPonCRUIinW0zWa/aU7hQsKd7fQ+cm5I8oF5q91krhuOFqGPDCvdtD0bf
qBKyuK5GBjNWhtHrQuKJMokaAix8W4oXUCAYZISlSQ1S2wDC/6PJKZe3jQTp1LCI
evyj8+HQ4dopbgpMFHZH6rs3G/CtDkxM8GZLVViyxYsxf2ViwrcRnwK8hQ7HcZaA
AAel5YMgCKgyEICpgqf5l7i+tfHypNewxI88/K1ohv+XcOj8hzHRpO62AtXxJoI=
=1Ms6
-----END PGP SIGNATURE-----

Hi Stefan,

Many thanks, that sounds like a good idea.
MarZone produces output files by default, and I could regularly check if the last output file has been produced.
But how can I do it in parallell to executing MarZone (I mean in the same script?), could you point me to the relevant command(s)?

Cheers
Stefan
________________________________________
Von: Stefan Lüdtke <sluedtke@gfz-potsdam.de>
Gesendet: Donnerstag, 30. Oktober 2014 09:19
An: Blumentrath, Stefan; grass-user@lists.osgeo.org
Betreff: Re: [GRASS-user] Stopping/killing a "puased" command

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Stefan,

can you pipe the MarZone output into a tmp file, check that file in
regular intervals for the desired string and stop the process if the
string is found. Not the most beautiful way I can think of but maybe
an option ..

Cheers,

Stefan

On 10/30/2014 09:06 AM, Blumentrath, Stefan wrote:

Hi,

I am trying to combine a commandline tool (MarZone) with GRASS in a
shell script (MSYS in OSGeo4W or Ubuntu).

The MarZone command should run in a loop where it recives new input
from GRASS in each iteration.

My scripts works in principle, however, unlike other command line
tools, MarZone does not end when it is done, but one has to press
enter to stop.

It ends with "Press return to exit." on screen.

In order to handle this in a loop, I simply kill the process after
the time I expect the sofware to run (plus a little time buffer):

Like this:

perl -e 'alarm shift @ARGV; exec @ARGV' 60 ./MarZone_x64.exe

Unfortunately, this is neither an effient nor a stable solution as
the time the software runs can vary quite a bit, depending on some
parameter settings.

My question is, is there a way to somehow catch, that the software
is ready (when it prints "Press return to exit."), an kill it
then?

Any idea?

Thanks for helping,

Stefan

_______________________________________________ grass-user mailing
list grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

- --
Stefan Lüdtke

Section 5.4- Hydrology
Tel.: +49 331 288 2821
Fax: +49 331 288 1570
Email: sluedtke@gfz-potsdam.de

Helmholtz-Zentrum Potsdam
Deutsches GeoForschungsZentrum GFZ
(GFZ German Research Centre for Geoscience)
Stiftung des öff. Rechts Land Brandenburg
Telegrafenberg, 14473 Potsdam
- -------------------

PGP Public Key: http://bit.ly/13d9Sca
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJUUfSTAAoJEB5GAbKcg+D8SLAH/1gAW/aMmCP4Ac3qgQFKQVBY
CK8OKH/I9ZAFUuG16uBj/fOZ2agm8N3Sz6xjZV9NDPk4pPz2PK3U2OTDT7DH8zeM
cvSJnETrPonCRUIinW0zWa/aU7hQsKd7fQ+cm5I8oF5q91krhuOFqGPDCvdtD0bf
qBKyuK5GBjNWhtHrQuKJMokaAix8W4oXUCAYZISlSQ1S2wDC/6PJKZe3jQTp1LCI
evyj8+HQ4dopbgpMFHZH6rs3G/CtDkxM8GZLVViyxYsxf2ViwrcRnwK8hQ7HcZaA
AAel5YMgCKgyEICpgqf5l7i+tfHypNewxI88/K1ohv+XcOj8hzHRpO62AtXxJoI=
=1Ms6
-----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

So maybe that's the part I did not consider ... :slight_smile:

The people more experienced in shell scripting might help here. I
would go and start MarZone with and ampersand

http://bashitout.com/2013/05/18/Ampersands-on-the-command-line.html

and than proceed in while loop ..

But that is all wild guessing ..

On 10/30/2014 09:27 AM, Blumentrath, Stefan wrote:

Hi Stefan,

Many thanks, that sounds like a good idea. MarZone produces output
files by default, and I could regularly check if the last output
file has been produced. But how can I do it in parallell to
executing MarZone (I mean in the same script?), could you point me
to the relevant command(s)?

Cheers Stefan ________________________________________ Von: Stefan
Lüdtke <sluedtke@gfz-potsdam.de> Gesendet: Donnerstag, 30. Oktober
2014 09:19 An: Blumentrath, Stefan; grass-user@lists.osgeo.org
Betreff: Re: [GRASS-user] Stopping/killing a "puased" command

Hi Stefan,

can you pipe the MarZone output into a tmp file, check that file
in regular intervals for the desired string and stop the process if
the string is found. Not the most beautiful way I can think of but
maybe an option ..

Cheers,

Stefan

On 10/30/2014 09:06 AM, Blumentrath, Stefan wrote:

Hi,

I am trying to combine a commandline tool (MarZone) with GRASS in
a shell script (MSYS in OSGeo4W or Ubuntu).

The MarZone command should run in a loop where it recives new
input from GRASS in each iteration.

My scripts works in principle, however, unlike other command
line tools, MarZone does not end when it is done, but one has to
press enter to stop.

It ends with "Press return to exit." on screen.

In order to handle this in a loop, I simply kill the process
after the time I expect the sofware to run (plus a little time
buffer):

Like this:

perl -e 'alarm shift @ARGV; exec @ARGV' 60 ./MarZone_x64.exe

Unfortunately, this is neither an effient nor a stable solution
as the time the software runs can vary quite a bit, depending on
some parameter settings.

My question is, is there a way to somehow catch, that the
software is ready (when it prints "Press return to exit."), an
kill it then?

Any idea?

Thanks for helping,

Stefan

_______________________________________________ grass-user
mailing list grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

- --
Stefan Lüdtke

Section 5.4- Hydrology
Tel.: +49 331 288 2821
Fax: +49 331 288 1570
Email: sluedtke@gfz-potsdam.de

Helmholtz-Zentrum Potsdam
Deutsches GeoForschungsZentrum GFZ
(GFZ German Research Centre for Geoscience)
Stiftung des öff. Rechts Land Brandenburg
Telegrafenberg, 14473 Potsdam
- -------------------

PGP Public Key: http://bit.ly/13d9Sca
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJUUfj2AAoJEB5GAbKcg+D8sLoH/1IvG7FzP2OjKRSD0U7BhvdV
75VdkAuvmqxEKKR9Qqg/tW0VE8R6sgh1b7awCrSe/z9ji+sSWaZ5lE+XXjjb2Tph
Yl0AHrRS/8YYp4f9ILzjytdd2KppQJwPvdVWBUcvpEOVMBBKIcQ0kTZBNM/lQLp1
Df+RrdqoEaWP6dXu+qLmMGFPjoPj3yVOwTLwQZsl24c5btCtzbwVTjNwNDm1AlMo
qp6H+NLp/sKwqa8/jAqw2QG2Je+rIm4AomgOj/LxE5e1a9gTk8xYiTRWP4fZf15V
77aiiCfB5TSv41VyS+JrbSc7qG7IV+RkX7WK30ESyB+Fxy+V1V5e9yZy6b8x9ME=
=B4/w
-----END PGP SIGNATURE-----

Great! Thanks! That looks very promising and should do the trick. I shall try that...
Many thanks again for your help!

Cheers
Stefan
________________________________________
Von: Stefan Lüdtke <sluedtke@gfz-potsdam.de>
Gesendet: Donnerstag, 30. Oktober 2014 09:38
An: Blumentrath, Stefan
Cc: grass-user
Betreff: Re: AW: [GRASS-user] Stopping/killing a "puased" command

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

So maybe that's the part I did not consider ... :slight_smile:

The people more experienced in shell scripting might help here. I
would go and start MarZone with and ampersand

http://bashitout.com/2013/05/18/Ampersands-on-the-command-line.html

and than proceed in while loop ..

But that is all wild guessing ..

On 10/30/2014 09:27 AM, Blumentrath, Stefan wrote:

Hi Stefan,

Many thanks, that sounds like a good idea. MarZone produces output
files by default, and I could regularly check if the last output
file has been produced. But how can I do it in parallell to
executing MarZone (I mean in the same script?), could you point me
to the relevant command(s)?

Cheers Stefan ________________________________________ Von: Stefan
Lüdtke <sluedtke@gfz-potsdam.de> Gesendet: Donnerstag, 30. Oktober
2014 09:19 An: Blumentrath, Stefan; grass-user@lists.osgeo.org
Betreff: Re: [GRASS-user] Stopping/killing a "puased" command

Hi Stefan,

can you pipe the MarZone output into a tmp file, check that file
in regular intervals for the desired string and stop the process if
the string is found. Not the most beautiful way I can think of but
maybe an option ..

Cheers,

Stefan

On 10/30/2014 09:06 AM, Blumentrath, Stefan wrote:

Hi,

I am trying to combine a commandline tool (MarZone) with GRASS in
a shell script (MSYS in OSGeo4W or Ubuntu).

The MarZone command should run in a loop where it recives new
input from GRASS in each iteration.

My scripts works in principle, however, unlike other command
line tools, MarZone does not end when it is done, but one has to
press enter to stop.

It ends with "Press return to exit." on screen.

In order to handle this in a loop, I simply kill the process
after the time I expect the sofware to run (plus a little time
buffer):

Like this:

perl -e 'alarm shift @ARGV; exec @ARGV' 60 ./MarZone_x64.exe

Unfortunately, this is neither an effient nor a stable solution
as the time the software runs can vary quite a bit, depending on
some parameter settings.

My question is, is there a way to somehow catch, that the
software is ready (when it prints "Press return to exit."), an
kill it then?

Any idea?

Thanks for helping,

Stefan

_______________________________________________ grass-user
mailing list grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

- --
Stefan Lüdtke

Section 5.4- Hydrology
Tel.: +49 331 288 2821
Fax: +49 331 288 1570
Email: sluedtke@gfz-potsdam.de

Helmholtz-Zentrum Potsdam
Deutsches GeoForschungsZentrum GFZ
(GFZ German Research Centre for Geoscience)
Stiftung des öff. Rechts Land Brandenburg
Telegrafenberg, 14473 Potsdam
- -------------------

PGP Public Key: http://bit.ly/13d9Sca
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJUUfj2AAoJEB5GAbKcg+D8sLoH/1IvG7FzP2OjKRSD0U7BhvdV
75VdkAuvmqxEKKR9Qqg/tW0VE8R6sgh1b7awCrSe/z9ji+sSWaZ5lE+XXjjb2Tph
Yl0AHrRS/8YYp4f9ILzjytdd2KppQJwPvdVWBUcvpEOVMBBKIcQ0kTZBNM/lQLp1
Df+RrdqoEaWP6dXu+qLmMGFPjoPj3yVOwTLwQZsl24c5btCtzbwVTjNwNDm1AlMo
qp6H+NLp/sKwqa8/jAqw2QG2Je+rIm4AomgOj/LxE5e1a9gTk8xYiTRWP4fZf15V
77aiiCfB5TSv41VyS+JrbSc7qG7IV+RkX7WK30ESyB+Fxy+V1V5e9yZy6b8x9ME=
=B4/w
-----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

you are welcome!

On 10/30/2014 10:04 AM, Blumentrath, Stefan wrote:

Great! Thanks! That looks very promising and should do the trick. I
shall try that... Many thanks again for your help!

Cheers Stefan ________________________________________ Von: Stefan
Lüdtke <sluedtke@gfz-potsdam.de> Gesendet: Donnerstag, 30. Oktober
2014 09:38 An: Blumentrath, Stefan Cc: grass-user Betreff: Re: AW:
[GRASS-user] Stopping/killing a "puased" command

So maybe that's the part I did not consider ... :slight_smile:

The people more experienced in shell scripting might help here. I
would go and start MarZone with and ampersand

http://bashitout.com/2013/05/18/Ampersands-on-the-command-line.html

and than proceed in while loop ..

But that is all wild guessing ..

On 10/30/2014 09:27 AM, Blumentrath, Stefan wrote:

Hi Stefan,

Many thanks, that sounds like a good idea. MarZone produces
output files by default, and I could regularly check if the last
output file has been produced. But how can I do it in parallell
to executing MarZone (I mean in the same script?), could you
point me to the relevant command(s)?

Cheers Stefan ________________________________________ Von:
Stefan Lüdtke <sluedtke@gfz-potsdam.de> Gesendet: Donnerstag, 30.
Oktober 2014 09:19 An: Blumentrath, Stefan;
grass-user@lists.osgeo.org Betreff: Re: [GRASS-user]
Stopping/killing a "puased" command

Hi Stefan,

can you pipe the MarZone output into a tmp file, check that file
in regular intervals for the desired string and stop the process
if the string is found. Not the most beautiful way I can think of
but maybe an option ..

Cheers,

Stefan

On 10/30/2014 09:06 AM, Blumentrath, Stefan wrote:

Hi,

I am trying to combine a commandline tool (MarZone) with GRASS
in a shell script (MSYS in OSGeo4W or Ubuntu).

The MarZone command should run in a loop where it recives new
input from GRASS in each iteration.

My scripts works in principle, however, unlike other command
line tools, MarZone does not end when it is done, but one has
to press enter to stop.

It ends with "Press return to exit." on screen.

In order to handle this in a loop, I simply kill the process
after the time I expect the sofware to run (plus a little time
buffer):

Like this:

perl -e 'alarm shift @ARGV; exec @ARGV' 60 ./MarZone_x64.exe

Unfortunately, this is neither an effient nor a stable
solution as the time the software runs can vary quite a bit,
depending on some parameter settings.

My question is, is there a way to somehow catch, that the
software is ready (when it prints "Press return to exit."), an
kill it then?

Any idea?

Thanks for helping,

Stefan

_______________________________________________ grass-user
mailing list grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

- --
Stefan Lüdtke

Section 5.4- Hydrology
Tel.: +49 331 288 2821
Fax: +49 331 288 1570
Email: sluedtke@gfz-potsdam.de

Helmholtz-Zentrum Potsdam
Deutsches GeoForschungsZentrum GFZ
(GFZ German Research Centre for Geoscience)
Stiftung des öff. Rechts Land Brandenburg
Telegrafenberg, 14473 Potsdam
- -------------------

PGP Public Key: http://bit.ly/13d9Sca
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJUUgArAAoJEB5GAbKcg+D8PV0H/i72p5+bRH3MoKx7fANKq2kO
metBFAY8vUBKStWE5OjSjqJjl+9P+4fh5rsvfb5gcF0gAEmoed3nykAtbZT6DmcP
mS23LL8YVqIeyADl3GBVANEKSHqX5ba/09tL+P+jB5j/dPzcoNalPX7zZC9y486Q
bA8l8n6R+m4WZaWAHrtqMyuwBVGn6W6MUKsueuVxf4DPZsWwPCTRnw3J1yhSrkqs
DfMlvKUsxXaNOdPmLpbmtQHhFxXai5wlZJP3/pZaHIbi11dtw5uPNMc2Mn/9dGbo
b2a+uoCfc5D23519HVQ38AbPS8a+wRYRA6dzA+YZaA22Db28UhXHb/13/G1E0Dk=
=advJ
-----END PGP SIGNATURE-----

Hi again,

it was as simple as this:

./MarZone_x64.exe &
wait

Neither while loop nor checking for files needed (http://stackoverflow.com/questions/14254118/waiting-for-background-processes-to-finish-before-exiting-script).
That one will save me hours in processing time and will avoid trouble with unexpectedly long running processes!

Cheers
Stefan
________________________________________
Von: Stefan Lüdtke <sluedtke@gfz-potsdam.de>
Gesendet: Donnerstag, 30. Oktober 2014 10:08
An: Blumentrath, Stefan
Cc: grass-user
Betreff: Re: AW: AW: [GRASS-user] Stopping/killing a "puased" command

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

you are welcome!

On 10/30/2014 10:04 AM, Blumentrath, Stefan wrote:

Great! Thanks! That looks very promising and should do the trick. I
shall try that... Many thanks again for your help!

Cheers Stefan ________________________________________ Von: Stefan
Lüdtke <sluedtke@gfz-potsdam.de> Gesendet: Donnerstag, 30. Oktober
2014 09:38 An: Blumentrath, Stefan Cc: grass-user Betreff: Re: AW:
[GRASS-user] Stopping/killing a "puased" command

So maybe that's the part I did not consider ... :slight_smile:

The people more experienced in shell scripting might help here. I
would go and start MarZone with and ampersand

http://bashitout.com/2013/05/18/Ampersands-on-the-command-line.html

and than proceed in while loop ..

But that is all wild guessing ..

On 10/30/2014 09:27 AM, Blumentrath, Stefan wrote:

Hi Stefan,

Many thanks, that sounds like a good idea. MarZone produces
output files by default, and I could regularly check if the last
output file has been produced. But how can I do it in parallell
to executing MarZone (I mean in the same script?), could you
point me to the relevant command(s)?

Cheers Stefan ________________________________________ Von:
Stefan Lüdtke <sluedtke@gfz-potsdam.de> Gesendet: Donnerstag, 30.
Oktober 2014 09:19 An: Blumentrath, Stefan;
grass-user@lists.osgeo.org Betreff: Re: [GRASS-user]
Stopping/killing a "puased" command

Hi Stefan,

can you pipe the MarZone output into a tmp file, check that file
in regular intervals for the desired string and stop the process
if the string is found. Not the most beautiful way I can think of
but maybe an option ..

Cheers,

Stefan

On 10/30/2014 09:06 AM, Blumentrath, Stefan wrote:

Hi,

I am trying to combine a commandline tool (MarZone) with GRASS
in a shell script (MSYS in OSGeo4W or Ubuntu).

The MarZone command should run in a loop where it recives new
input from GRASS in each iteration.

My scripts works in principle, however, unlike other command
line tools, MarZone does not end when it is done, but one has
to press enter to stop.

It ends with "Press return to exit." on screen.

In order to handle this in a loop, I simply kill the process
after the time I expect the sofware to run (plus a little time
buffer):

Like this:

perl -e 'alarm shift @ARGV; exec @ARGV' 60 ./MarZone_x64.exe

Unfortunately, this is neither an effient nor a stable
solution as the time the software runs can vary quite a bit,
depending on some parameter settings.

My question is, is there a way to somehow catch, that the
software is ready (when it prints "Press return to exit."), an
kill it then?

Any idea?

Thanks for helping,

Stefan

_______________________________________________ grass-user
mailing list grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

- --
Stefan Lüdtke

Section 5.4- Hydrology
Tel.: +49 331 288 2821
Fax: +49 331 288 1570
Email: sluedtke@gfz-potsdam.de

Helmholtz-Zentrum Potsdam
Deutsches GeoForschungsZentrum GFZ
(GFZ German Research Centre for Geoscience)
Stiftung des öff. Rechts Land Brandenburg
Telegrafenberg, 14473 Potsdam
- -------------------

PGP Public Key: http://bit.ly/13d9Sca
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJUUgArAAoJEB5GAbKcg+D8PV0H/i72p5+bRH3MoKx7fANKq2kO
metBFAY8vUBKStWE5OjSjqJjl+9P+4fh5rsvfb5gcF0gAEmoed3nykAtbZT6DmcP
mS23LL8YVqIeyADl3GBVANEKSHqX5ba/09tL+P+jB5j/dPzcoNalPX7zZC9y486Q
bA8l8n6R+m4WZaWAHrtqMyuwBVGn6W6MUKsueuVxf4DPZsWwPCTRnw3J1yhSrkqs
DfMlvKUsxXaNOdPmLpbmtQHhFxXai5wlZJP3/pZaHIbi11dtw5uPNMc2Mn/9dGbo
b2a+uoCfc5D23519HVQ38AbPS8a+wRYRA6dzA+YZaA22Db28UhXHb/13/G1E0Dk=
=advJ
-----END PGP SIGNATURE-----