#36830 - 2003-02-22 06:53 AM
How to run a separate CMD window for each command
|
bekoz
Fresh Scripter
Registered: 2002-11-07
Posts: 20
|
I havent been able to figure out or find info on opening a separate dos window for each command that I want to execute. I want to run a bunch of tail comands, each in it's own window. Can someone please help.
|
|
Top
|
|
|
|
#36831 - 2003-02-22 07:11 AM
Re: How to run a separate CMD window for each command
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
use the start command
quote: G:\>start /? Starts a separate window to run a specified program or command.
START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/WAIT] [/B] [command/program] [parameters]
"title" Title to display in window title bar. path Starting directory B Start application without creating a new window. The application has ^C handling ignored. Unless the application enables ^C processing, ^Break is the only way to interrupt the application I The new environment will be the original environment passed to the cmd.exe and not the current environment. MIN Start window minimized MAX Start window maximized SEPARATE Start 16-bit Windows program in separate memory space SHARED Start 16-bit Windows program in shared memory space LOW Start application in the IDLE priority class NORMAL Start application in the NORMAL priority class HIGH Start application in the HIGH priority class REALTIME Start application in the REALTIME priority class ABOVENORMAL Start application in the ABOVENORMAL priority class BELOWNORMAL Start application in the BELOWNORMAL priority class WAIT Start application and wait for it to terminate command/program If it is an internal cmd command or a batch file then the command processor is run with the /K switch to cmd.exe. This means that the window will remain after the command has been run.
If it is not an internal cmd command or batch file then it is a program and will run as either a windowed application or a console application.
parameters These are the parameters passed to the command/program
If Command Extensions are enabled, external command invocation through the command line or the START command changes as follows:
non-executable files may be invoked through their file association just by typing the name of the file as a command. (e.g. WORD.DOC would launch the application associated with the .DOC file extension). See the ASSOC and FTYPE commands for how to create these associations from within a command script.
When executing an application that is a 32-bit GUI application, CMD.EXE does not wait for the application to terminate before returning to the command prompt. This new behavior does NOT occur if executing within a command script.
Press any key to continue . . .
|
|
Top
|
|
|
|
#36832 - 2003-02-22 07:55 AM
Re: How to run a separate CMD window for each command
|
bekoz
Fresh Scripter
Registered: 2002-11-07
Posts: 20
|
Can you run multiple commands with the start command? For example:
tail -f something | grep something
|
|
Top
|
|
|
|
#36833 - 2003-02-22 08:18 AM
Re: How to run a separate CMD window for each command
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Most things (within reason) that you can normally do from a command prompt can be shelled out and done as well from KiXtart.
Please post what version of KiXtart you are using also the client OS it is intended to run on. Then a sample of how you are currently doing it.
I'm sure someone here can help you get it going.
Wow Bryce... I just noticed I've posted more then you. I guess all that time off really hurt your post count. Welcome back again to the KORG ![[Big Grin]](images/icons/grin.gif) [ 22. February 2003, 08:21: Message edited by: NTDOC ]
|
|
Top
|
|
|
|
#36834 - 2003-02-22 08:27 AM
Re: How to run a separate CMD window for each command
|
bekoz
Fresh Scripter
Registered: 2002-11-07
Posts: 20
|
KIX 4.20 OS Win2000
This is what I'm doing
Break On
$date = @DATE ; Date in YYYY/MM/DD format
$ly = SubStr($date,1,4) ; Year in YYYY format parsed from $date $y = SubStr($date,3,2) ; Year in YY format parsed from $date $m = SubStr($date,6,2) ; Month in MM format parsed from $date $d = SubStr($date,9,2) ; Day in DD format parsed from $date $pd = "" $sd = Val($d) ; Single digit version of day $sm = Val($m) ; Single digit version of month
$RCCT1 = "L:\path\log_2003_" + $sm + "_" + $sd + ".txt"
$grep = "| grep32 " $profile = Chr(34) + "I3GetProfile: Profile properties loaded:" + Chr(34)
$tail1 = "tail -f $RCCT1 $grep $profile"
If Exist('$RCCT1') Shell '%comspec% /c start /separate $tail1' EndIf
The script opens up another window with the tail comand but omits the grep portion. That is the part I'm stuck on.
|
|
Top
|
|
|
|
#36836 - 2003-02-22 11:33 AM
Re: How to run a separate CMD window for each command
|
bekoz
Fresh Scripter
Registered: 2002-11-07
Posts: 20
|
Tail allows yopu to view a log file on screen as it's being written to. That's all I'm trying to do. To see the files being written to. No searches. Not doing anything with the info afterwards. It's for monitoring purposes.
|
|
Top
|
|
|
|
#36838 - 2003-02-22 11:45 AM
Re: How to run a separate CMD window for each command
|
bekoz
Fresh Scripter
Registered: 2002-11-07
Posts: 20
|
Yes, Thanks. The command works and the output is seen in the command window. Just that it works partially. The part after the pipe does not work the way I'm trying to use it here. The command fully works when I use it in a DOS window on it's own or from a batch file. I was hoping there was a way to do it using KIX with no batch files. I wanted to keep it cleaner.
|
|
Top
|
|
|
|
#36840 - 2003-02-22 03:59 PM
Re: How to run a separate CMD window for each command
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
|
I don't believe you can grep from a tail -f, since the tail holds the output open until it is terminated.. the pipe would wait for a close. When I run the "tail -f file | grep something" at a command line, I get nothing at all. I get the same results with the DOS and Korn shells, btw.
At least, thats what appears to happen on my workstation with MKS Toolkit.
Here's my sample code (z.kix), which opens 3 windows.
"X.Kix" sits in an infinite loop writing to three files (since I don't have any other active files to monitor). It simulates your app writing to multiple log files.
"z.kix" kicks off the log generator (x.kix) and then initiates three windows to monitor the output. Once I invoke the window, I see tail displaying ALL of the lines written to the file - grep has no effect.
At least you know you aren't pulling hair out for no reason.. it's an O/S limitation. I can't get onto a *nix system now to confirm how it would work there..
Glenn
code:
; x.kix - simulate constant writing to 3 logfiles Break ON
Srnd(@TICKS)
$STAT = "|","/","-","\" $CNT = 0
while 1
$MSG = CStr(Rnd(5)) + ": some status message@CRLF" $RTN = Open(4, "C:\Temp\File1", 5) $RTN = WriteLine(4, $MSG) $RTN = Close(4)
$MSG = CStr(Rnd(5)) + ": some status message@CRLF" $RTN = Open(4, "C:\Temp\File2", 5) $RTN = WriteLine(4, $MSG) $RTN = Close(4)
$MSG = CStr(Rnd(5)) + ": some status message@CRLF" $RTN = Open(4, "C:\Temp\File3", 5) $RTN = WriteLine(4, $MSG) $RTN = Close(4)
; display some sort of status that we're working.. $STAT[$CNT] + Chr(13) $CNT = $CNT + 1 If $CNT = 3 $CNT = 0 EndIf
Sleep 0.5
Loop
code:
; z.kix - open 3 monitor windows ; Must monitor three files (file1, file2, and file3) which have status codes 1-5 ; Files are written to constantly - must display all status "3" events ; Use Kix to start 3 monitor windows using "tail -f | grep 3" from Posix tools
"Starting" ? ; start the log file simulator Shell "start kix32 c:\temp\x.kix"
; open separate windows to monitor 3 files $FILES = "file1","file2","file3" For Each $FILE in $FILES $CMD = "start tail -f C:\Temp\" + $FILE + " | grep 3" ? "Monitoring $FILE" Shell $CMD Next
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#36842 - 2003-02-25 01:26 PM
Re: How to run a separate CMD window for each command
|
bekoz
Fresh Scripter
Registered: 2002-11-07
Posts: 20
|
I tail some logs during my shift just to insure allication functionality from a central location (my computer), so I don't have to monitor applications on various monitors hooked through KVMs. Just saevs time and effort rather than scrolling throgh a bunch of displays. And those displays tell you less than the logs.
|
|
Top
|
|
|
|
#36843 - 2003-02-25 01:32 PM
Re: How to run a separate CMD window for each command
|
bekoz
Fresh Scripter
Registered: 2002-11-07
Posts: 20
|
Glenn, you can grep in a tail -f command. I do it all the time and it works. Its actually very useful for catching only the info you want.
LLigetfa, That's what I want to achieve. Let me try that. Maybe I was getting too wild with the quotes.
|
|
Top
|
|
|
|
#36846 - 2003-02-25 05:17 PM
Re: How to run a separate CMD window for each command
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Ok, I've just tried again and is simply works for me.
A KiXtart script with the following:
code:
Shell '%COMSPEC% /C tail -f foo.txt | grep "e d"'
Waits happily, and displays matching lines if I send them with DOS commands like "echo some data >>foo.txt"
I'm using tools downloaded from various places (like Gnu-Win32). Apart from not costing anything I find they are more like their *nix counterparts than commercial offerings, and are usually more up-to-date. No support though
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 823 anonymous users online.
|
|
|