sin

I want to make a script to execute a program pgmx, before this the script
need to check if the pgmx is in memory (already running).

I have try with;

sin -h -P pgmx format i

and the sin don’t have a return code. If the program is running, this
working but if it’s not the sin return;

sin: no process(es) found.

i try to catch it with this command;

RESULT=sin -h -P pgmx format i | cut -c1-5

and if the program is not running RESULT have a blank string on it.

Do someone have done this in a script or by a Watcom command.

Thanks Roger.


Sigma Automatisation Inc.
Roger Parent
6 Patrice Cote C.P.130
Trois-Pistoles, Qc G0L 4K0
Tel: 418-851-4254 ou 418-857-2172 Ext 121
Fax: 418-851-4580
Email: rparent@sigma-techno.com
Web: www.sigma-techno.com

I wouldn’t to this from the script, I would rather let pgmx do its own
checking.

“Roger Parent @ Sigma inc.” <rparent@sigma-techno.com> wrote in message
news:96bcl6$8lj$1@inn.qnx.com

I want to make a script to execute a program pgmx, before this the script
need to check if the pgmx is in memory (already running).

I have try with;

sin -h -P pgmx format i

and the sin don’t have a return code. If the program is running, this
working but if it’s not the sin return;

sin: no process(es) found.

i try to catch it with this command;

RESULT=sin -h -P pgmx format i | cut -c1-5

and if the program is not running RESULT have a blank string on it.

Do someone have done this in a script or by a Watcom command.

Thanks Roger.


Sigma Automatisation Inc.
Roger Parent
6 Patrice Cote C.P.130
Trois-Pistoles, Qc G0L 4K0
Tel: 418-851-4254 ou 418-857-2172 Ext 121
Fax: 418-851-4580
Email: > rparent@sigma-techno.com
Web: > www.sigma-techno.com

Ok, but how i can do this ?

“Mario Charest” <mcharest@void_zinformatic.com> a écrit dans le message
news: 96begs$6tv$1@nntp.qnx.com

I wouldn’t to this from the script, I would rather let pgmx do its own
checking.

“Roger Parent @ Sigma inc.” <> rparent@sigma-techno.com> > wrote in message
news:96bcl6$8lj$> 1@inn.qnx.com> …
I want to make a script to execute a program pgmx, before this the
script
need to check if the pgmx is in memory (already running).

I have try with;

sin -h -P pgmx format i

and the sin don’t have a return code. If the program is running, this
working but if it’s not the sin return;

sin: no process(es) found.

i try to catch it with this command;

RESULT=sin -h -P pgmx format i | cut -c1-5

and if the program is not running RESULT have a blank string on it.

Do someone have done this in a script or by a Watcom command.

Thanks Roger.


Sigma Automatisation Inc.
Roger Parent
6 Patrice Cote C.P.130
Trois-Pistoles, Qc G0L 4K0
Tel: 418-851-4254 ou 418-857-2172 Ext 121
Fax: 418-851-4580
Email: > rparent@sigma-techno.com
Web: > www.sigma-techno.com


\

Sorry.

If your program attach a name (qnx_name_attach() ) or any other easy
to detect resource, just check if the resource already exits.

If not scan the list of running processes to check if a process with
the name ABCD is already running:

int id;
int count;
struct _psinfo data;


id = 0;
count = 0;

while( ( id = qnx_psinfo( 0, ++id, &data, 0, 0 ) ) != -1 ) {
if ( data.un.proc.name ) { // robustness
char *p;
p = strrchr( data.un.proc.name, ‘/’ ); // extract program name
if ( p ) {
if ( strstr( p, “program name” ) ) {
++count;
}
}
}
}

return count;

The following isn’t perfect because of the use of strstr.
If a program call abcdefg is running and your program is
called abcd, since abcd is a subset of abcdefg strstr will
succeed.

“Roger Parent @ Sigma inc.” <rparent@sigma-techno.com> wrote in message
news:96bego$9nv$1@inn.qnx.com

Ok, but how i can do this ?

“Mario Charest” <mcharest@void_zinformatic.com> a écrit dans le message
news: 96begs$6tv$> 1@nntp.qnx.com> …

I wouldn’t to this from the script, I would rather let pgmx do its own
checking.

“Roger Parent @ Sigma inc.” <> rparent@sigma-techno.com> > wrote in message
news:96bcl6$8lj$> 1@inn.qnx.com> …
I want to make a script to execute a program pgmx, before this the
script
need to check if the pgmx is in memory (already running).

I have try with;

sin -h -P pgmx format i

and the sin don’t have a return code. If the program is running, this
working but if it’s not the sin return;

sin: no process(es) found.

i try to catch it with this command;

RESULT=sin -h -P pgmx format i | cut -c1-5

and if the program is not running RESULT have a blank string on it.

Do someone have done this in a script or by a Watcom command.

Thanks Roger.


Sigma Automatisation Inc.
Roger Parent
6 Patrice Cote C.P.130
Trois-Pistoles, Qc G0L 4K0
Tel: 418-851-4254 ou 418-857-2172 Ext 121
Fax: 418-851-4580
Email: > rparent@sigma-techno.com
Web: > www.sigma-techno.com




\

The qnx_psinfo need the pid, i don’t want give the pid, i want to give the
process name like i can do with sin -P pgmx.

I don’t want to check all process to see if the of the process fit’s with
the name i got(pmgx).

Do you know another method, like OS method.

“Mario Charest” <mcharest@void_zinformatic.com> a écrit dans le message
news: 96bjii$9mq$1@nntp.qnx.com

Sorry.

If your program attach a name (qnx_name_attach() ) or any other easy
to detect resource, just check if the resource already exits.

If not scan the list of running processes to check if a process with
the name ABCD is already running:

int id;
int count;
struct _psinfo data;


id = 0;
count = 0;

while( ( id = qnx_psinfo( 0, ++id, &data, 0, 0 ) ) != -1 ) {
if ( data.un.proc.name ) { // robustness
char *p;
p = strrchr( data.un.proc.name, ‘/’ ); // extract program name
if ( p ) {
if ( strstr( p, “program name” ) ) {
++count;
}
}
}
}

return count;

The following isn’t perfect because of the use of strstr.
If a program call abcdefg is running and your program is
called abcd, since abcd is a subset of abcdefg strstr will
succeed.

“Roger Parent @ Sigma inc.” <> rparent@sigma-techno.com> > wrote in message
news:96bego$9nv$> 1@inn.qnx.com> …
Ok, but how i can do this ?

“Mario Charest” <mcharest@void_zinformatic.com> a écrit dans le message
news: 96begs$6tv$> 1@nntp.qnx.com> …

I wouldn’t to this from the script, I would rather let pgmx do its own
checking.

“Roger Parent @ Sigma inc.” <> rparent@sigma-techno.com> > wrote in
message
news:96bcl6$8lj$> 1@inn.qnx.com> …
I want to make a script to execute a program pgmx, before this the
script
need to check if the pgmx is in memory (already running).

I have try with;

sin -h -P pgmx format i

and the sin don’t have a return code. If the program is running,
this
working but if it’s not the sin return;

sin: no process(es) found.

i try to catch it with this command;

RESULT=sin -h -P pgmx format i | cut -c1-5

and if the program is not running RESULT have a blank string on it.

Do someone have done this in a script or by a Watcom command.

Thanks Roger.


Sigma Automatisation Inc.
Roger Parent
6 Patrice Cote C.P.130
Trois-Pistoles, Qc G0L 4K0
Tel: 418-851-4254 ou 418-857-2172 Ext 121
Fax: 418-851-4580
Email: > rparent@sigma-techno.com
Web: > www.sigma-techno.com






\

Roger Parent @ Sigma inc. <rparent@sigma-techno.com> wrote:

The qnx_psinfo need the pid, i don’t want give the pid, i want to give the
process name like i can do with sin -P pgmx.

I don’t want to check all process to see if the of the process fit’s with
the name i got(pmgx).

You may not realize it, but what sin does is, essentially, the code
presented – it takes the string, and queries every pid, gets the
name for that process, and compares the string you gave it to the
name of the process.

(In other words, “sin -P pgmx” does check every process – you just don’t
realize it is doing so.)

Do you know another method, like OS method.

There isn’t such. The OS supplies tools like qnx_name_attach() &
qnx_name_locate(), or qnx_prefix_attach() & open() for finding and
talking to other processes. But, you have to be dealing with a process
that has attached the particular resource – name or pathname. Note
that if a process dies, the OS will clean up the resource.

-David

QNX Training Services
dagibbs@qnx.com

“Roger Parent @ Sigma inc.” <rparent@sigma-techno.com> wrote in message
news:96born$g0t$1@inn.qnx.com

The qnx_psinfo need the pid, i don’t want give the pid, i want to give the
process name like i can do with sin -P pgmx.

You don’t provide the pid you start with a pid of 0 and start the scan from
there.

I don’t want to check all process to see if the of the process fit’s with
the name i got(pmgx).

There can’t be any black magic here, somebody has to scan the list
of process to see if one exists. In this case the OS/lib doesn’t
provide a function to do it for you, so you have to do it yourself.
Just turn the snippet of code I post into a function, put it
in a library and forget it’s “scanning” :wink:

Do you know another method, like OS method.

Well this is an OS method.

If you want to to it the hard way you could do.

f = popen( “sin -P pgmx”);
read(f…);
close(f);

Then you can parse the data return by read().

“Mario Charest” <mcharest@void_zinformatic.com> a écrit dans le message
news: 96bjii$9mq$> 1@nntp.qnx.com> …

Sorry.

If your program attach a name (qnx_name_attach() ) or any other easy
to detect resource, just check if the resource already exits.

If not scan the list of running processes to check if a process with
the name ABCD is already running:

int id;
int count;
struct _psinfo data;


id = 0;
count = 0;

while( ( id = qnx_psinfo( 0, ++id, &data, 0, 0 ) ) != -1 ) {
if ( data.un.proc.name ) { // robustness
char *p;
p = strrchr( data.un.proc.name, ‘/’ ); // extract program name
if ( p ) {
if ( strstr( p, “program name” ) ) {
++count;
}
}
}
}

return count;

The following isn’t perfect because of the use of strstr.
If a program call abcdefg is running and your program is
called abcd, since abcd is a subset of abcdefg strstr will
succeed.

“Roger Parent @ Sigma inc.” <> rparent@sigma-techno.com> > wrote in message
news:96bego$9nv$> 1@inn.qnx.com> …
Ok, but how i can do this ?

“Mario Charest” <mcharest@void_zinformatic.com> a écrit dans le
message
news: 96begs$6tv$> 1@nntp.qnx.com> …

I wouldn’t to this from the script, I would rather let pgmx do its
own
checking.

“Roger Parent @ Sigma inc.” <> rparent@sigma-techno.com> > wrote in
message
news:96bcl6$8lj$> 1@inn.qnx.com> …
I want to make a script to execute a program pgmx, before this the
script
need to check if the pgmx is in memory (already running).

I have try with;

sin -h -P pgmx format i

and the sin don’t have a return code. If the program is running,
this
working but if it’s not the sin return;

sin: no process(es) found.

i try to catch it with this command;

RESULT=sin -h -P pgmx format i | cut -c1-5

and if the program is not running RESULT have a blank string on
it.

Do someone have done this in a script or by a Watcom command.

Thanks Roger.


Sigma Automatisation Inc.
Roger Parent
6 Patrice Cote C.P.130
Trois-Pistoles, Qc G0L 4K0
Tel: 418-851-4254 ou 418-857-2172 Ext 121
Fax: 418-851-4580
Email: > rparent@sigma-techno.com
Web: > www.sigma-techno.com








\

In article <96bcl6$8lj$1@inn.qnx.com>,
Roger Parent @ Sigma inc. <rparent@sigma-techno.com> wrote:

I want to make a script to execute a program pgmx, before this the script
need to check if the pgmx is in memory (already running).

slay -Q -s0 pgmx


Garry Turcotte (R&D)
QNX Software Systems, Ltd.

Thanks Garry,

this working fine, do you know where i can find a list of signal, -s0 means
what, and the other signal ?


“Garry Turcotte” <garry@qnx.com> a écrit dans le message news:
96bs2l$edp$1@nntp.qnx.com

In article <96bcl6$8lj$> 1@inn.qnx.com> >,
Roger Parent @ Sigma inc. <> rparent@sigma-techno.com> > wrote:
I want to make a script to execute a program pgmx, before this the script
need to check if the pgmx is in memory (already running).


slay -Q -s0 pgmx


Garry Turcotte (R&D)
QNX Software Systems, Ltd.

Still scanning underneath. :slight_smile:

Garry Turcotte wrote:

In article <96bcl6$8lj$> 1@inn.qnx.com> >,
Roger Parent @ Sigma inc. <> rparent@sigma-techno.com> > wrote:
I want to make a script to execute a program pgmx, before this the script
need to check if the pgmx is in memory (already running).


slay -Q -s0 pgmx


Garry Turcotte (R&D)
QNX Software Systems, Ltd.

Roger Parent @ Sigma inc. <rparent@sigma-techno.com> wrote:

Thanks Garry,

this working fine, do you know where i can find a list of signal, -s0 means
what, and the other signal ?

-s0 means send signal 0 – which just tests for the existence.

BUT, this just has the exact same loop underneath – this time the loop
is inside slay, instead of inside you code. (And, anything that runs a
new program to run the loop for you is going to be FAR less efficient than
just writing a function that runs the loop.)

-David

QNX Training Services
dagibbs@qnx.com

I know this, that what i need, if in the future i need to this in my program
i will use qnx_psinfo.

“David Gibbs” <dagibbs@qnx.com> a écrit dans le message news:
96bvou$g31$1@nntp.qnx.com

Roger Parent @ Sigma inc. <> rparent@sigma-techno.com> > wrote:
Thanks Garry,

this working fine, do you know where i can find a list of signal, -s0
means
what, and the other signal ?

-s0 means send signal 0 – which just tests for the existence.

BUT, this just has the exact same loop underneath – this time the loop
is inside slay, instead of inside you code. (And, anything that runs a
new program to run the loop for you is going to be FAR less efficient than
just writing a function that runs the loop.)

-David

QNX Training Services
dagibbs@qnx.com