EcecCmd - mysqladmin with pipe - doesnt work
Hi all,
I am hoping someone can give some advise on the problem I'm having with the installer I'm writing. I have decided I need to use ExecDos or ExecCmd as I need to perform a console operation without showing a Cmd window.
the command I am actually trying to perfom is this:
[PATH]\mysqladmin.exe --defaults-file=[PATH]\my-small****f --user=root --password=root variables | find "basedir" | find "[EXPECTEDBASEDIR]"
The purpose is to launch mysqladmin and find the basedir from the variables output, and thus checking that it is the expected basedir. IE it is OUR mysql server that is running.
So the expected NSIS code is:
;Assuming ${MYSQL} contains the relative path to the mysql directory
ExecCmd::exec '${MYSQL}\bin\mysqladmin.exe --defaults-file=${MYSQL}\bin\my-small****f --user=root --pass=root variables | find "basedir" | find "[EXPECTEDBASEDIR]"'
This works fine when the mysqlserver is up (returns 0 to stack if ffound, 1 otherwise. And also returns 1 as expected if the mysqlserver is not running.
However if the ****f file is configured to listen to a port number that is already in a listening state (for example 80 or any port Apache is running on), mysqladmin hangs for a long period of time.
No problem, thats why we have the /TIMEOUT switch! so the new code is this:
;Assuming ${MYSQL} contains the relative path to the mysql directory
ExecCmd::exec /TIMEPOUT=10000 '${MYSQL}\bin\mysqladmin.exe --defaults-file=${MYSQL}\bin\my-small****f --user=root --pass=root variables | find "basedir" | find "[EXPECTEDBASEDIR]"'
And sure enought the timeout works and pops a nice -8 return value. however there is a problem. After performing the above command and returning from the exec call, the processes (mysqladmin.exe, and 2 instances of find.exe) continue to run and not cease like expected with ExecCmd...
With testing, if I run the cmd with just mysqladmin (removing the 2 calls to find and the 2 pipes) then ExecCmd kills mysqladmin.exe correctly, but not when the output is piped to another app (in this case find)
can anyone help solve this issue?
I cant just leave mysqladmin to timeout and die on its own as the situation can arise where the installer completes but there are still child processes running, which may need to be re-used, and which is against our coding guidelines and is very poor practice.
I do hope someone can help!
Many thanks in advance,
Danny