Page 1 of 1 1
Topic Options
#7364 - 2001-03-06 05:25 PM shell command
Anonymous
Unregistered


Hi everybody,

i want to check, if an application is running.
So i use the following script, wich works just fine. The programm tlist from NT res Kit does the main part.

$process = "akit.exe"
SHELL '%comspec% /c tlist | find /i "$process" >nul'

IF @ERROR = 0
?"$process is running..."
ELSE
?"$process is not running..."
ENDIF

This way, program tlist must be within the working directory.

Using a full qualified path like

SHELL '%comspec% /c \\GUI-SERVER\GUI\tlist | find /i "$process" >nul'

still works.

But i can't figure out how to change the path to a variable like

$path = "\\GUI-SERVER\GUI\"
$process = "akit.exe"
SHELL '%comspec% /c "$path"tlist | find /i "$process" >nul'

This way, tlist is not found.
What is the correct syntax for using variables within the shell command?

Any hint is appreciated!

GOGO


Top
#7365 - 2001-03-06 06:13 PM Re: shell command
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
GOGO

Try it this way...

$path = "\\GUI-SERVER\GUI"

$process = "akit.exe"

SHELL '%comspec% /c $path\tlist | find /i "$process" >nul'

Shawn.

[This message has been edited by Shawn (edited 06 March 2001).]

Top
#7366 - 2001-03-07 09:10 AM Re: shell command
Anonymous
Unregistered


Thanks Shawn,

it works well, but...

I just don't understand the syntax.
Why can I use $process with and $path without quotation marks?
I do need the " quotation marks around $process and it's not possible to change ' and ".
What are the rules?

Usually I don't have logic problems within my scrips, but always a hard time about variables and syntax.
Sorry Ruud, but the documentation doesn't help me much.

Top
#7367 - 2001-03-07 04:00 PM Re: shell command
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
GOGO,

Here is a hint on how I sometimes create complex shell/syntax commands.

using the code as an example....

first you set all of the variables.

$path = "\\GUI-SERVER\GUI"
$process = "akit.exe"

then instead of actually doing a shell command. Just print "?" the shell string, this will let you show you what the finished shell command will be, after the variables are defined.

? '%comspec% /c $path\tlist | find /i "$process" >nul'

quote:

C:\WINNT\system32\cmd.exe /c \\GUI-SERVER\GUI\tlist | find /i "akit.exe" >nul

now print the shell string from what you posted,

? '%comspec% /c "$path"tlist | find /i "$process" >nul'

quote:

C:\WINNT\system32\cmd.exe /c "\\GUI-SERVER\GUI"tlist | find /i "akit.exe" >nul

see the error in the syntax?

Bryce


------------------
kix.isorg.net

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 937 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.118 seconds in which 0.091 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org