How to get the port number from a scm daemon start command sent in a batch file
I am trying to start a daemon, do some work with it then terminate it on completion
I can do
start "my name" scm daemon start --port 49000
and then
scm daemon stop --port 49000
but cannot redirect the console application like so : -
start "my name" scm daemon start 2>%TEMP%\portLoc.txt
or
start "my name" scm daemon start >%TEMP%\portLoc.txt
or about three other variations used to get the port number, I don't want to kill all instances of scm. The number I want is there in the console window, but I can't get at it. I'd like not to hard code the port number to avoid using a port already in use or maybe errors when running the application twice. Any hints? Thanks
Richard
2 answers
It looks like you need to escape the redirection character.
See http://superuser.com/questions/338277/windows-cmd-batch-start-and-output-redirection for some hints and tips.
See http://superuser.com/questions/338277/windows-cmd-batch-start-and-output-redirection for some hints and tips.
Try this:
I understand that you will then find out the port number in the file myName.log for the use of "scm daemon stop". If the command works for you, you will not get any new command windows, so the title of the start command "my name" is of no use, and you should use the log file name to identify your daemon.
start /b scm.exe daemon start > myName.log 2>&1
I understand that you will then find out the port number in the file myName.log for the use of "scm daemon stop". If the command works for you, you will not get any new command windows, so the title of the start command "my name" is of no use, and you should use the log file name to identify your daemon.