Re: [Lazarus] Getting MySQL process output
> is it maybe sent via something other than STDOUT? STDERR perhaps? for > security reasons maybe? Nothing! :| > Process := TProcess.Create(nil); with Process do begin Executable > := '"C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin\mysql.exe" -u > root -p'; with Parameters do begin Options := [poUsePipes, > poNoConsole]; end; Execute; Sleep(1000); > WriteLn(Process.Output.NumBytesAvailable); // will be 0 but it write > "Enter password" WriteLn(Process.Stderr.NumBytesAvailable); // > will be 0 but it write "Enter password" end; Regards, Ara -- http://www.fastmail.com - IMAP accessible web-mail -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Getting MySQL process output
On 12/05/2015 12:37 PM, Aradeonas wrote: Did you use the poNoConsole option ? Yes and NumByteAvailable is 0 but it write "Enter Password" message in console. I can understand why this message goes in Lazarus output or wherever except output of TProcess. is it maybe sent via something other than STDOUT? STDERR perhaps? for security reasons maybe? -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Getting MySQL process output
> Did you use the poNoConsole option ? Yes and NumByteAvailable is 0 but it write "Enter Password" message in console. I can understand why this message goes in Lazarus output or wherever except output of TProcess. Regards, Ara -- http://www.fastmail.com - Access all of your messages and folders wherever you are -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Getting MySQL process output
On Sat, 5 Dec 2015, Aradeonas wrote: What is the -WG param ? I could not find it in the documentation. Win32 GUI application in compiler option> conf and target If you are afraid that it will be visible in the task list, just set the MYSQL_PWD and USER environment variables in TProcess. Good point. All in all, I suspect you would probably be better off using the mysql library. The mysql command is just a front-end to that. As I said in my first question is not just a MySQL problem, for this case I need to connect to mysql cmd not library and for that I need to communicate with it and write SQl query and send and then receive the result. I just dont know how read its output,its not like a simple CMD program that you run and get the output simply. Did you use the poNoConsole option ? Michael. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Getting MySQL process output
> What is the -WG param ? I could not find it in the documentation. Win32 GUI application in compiler option> conf and target > If you are afraid that it will be visible in the task list, just set > the MYSQL_PWD and USER environment variables in TProcess. Good point. > All in all, I suspect you would probably be better off using the mysql > library. The mysql command is just a front-end to that. As I said in my first question is not just a MySQL problem, for this case I need to connect to mysql cmd not library and for that I need to communicate with it and write SQl query and send and then receive the result. I just dont know how read its output,its not like a simple CMD program that you run and get the output simply. Regards, Ara -- http://www.fastmail.com - Faster than the air-speed velocity of an unladen european swallow -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Getting MySQL process output
On Sat, 5 Dec 2015, Aradeonas wrote: Simple Loop: - Read from program output - interpret the output and - write to program input. That's all the "general" advice we can give. Yea sure I do this and I have no problem with simple CMD programs. Problem is programs like MySQL that can be run from one line command and need reading and writing. When you run this command : '"C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin\mysql.exe" -u root -p'; You will get nothing in the output, it is locked and you even cant call NumByteAvailable but interesting is if you remove -WG param you can see Enter password: it will write in CMD that opens with program it self from Lazarus. What is the -WG param ? I could not find it in the documentation. I also don't understand why you don't specify the password on the command-line, then you would not have these problems. If you are afraid that it will be visible in the task list, just set the MYSQL_PWD and USER environment variables in TProcess. All in all, I suspect you would probably be better off using the mysql library. The mysql command is just a front-end to that. Michael.-- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Getting MySQL process output
> Simple Loop: - Read from program output - interpret the output and - write to program input. That's all the "general" advice we can give. Yea sure I do this and I have no problem with simple CMD programs. Problem is programs like MySQL that can be run from one line command and need reading and writing. When you run this command : '"C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin\mysql.exe" -u root -p'; You will get nothing in the output, it is locked and you even cant call NumByteAvailable but interesting is if you remove -WG param you can see Enter password: it will write in CMD that opens with program it self from Lazarus. Regards, Ara -- http://www.fastmail.com - Same, same, but different... -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Getting MySQL process output
On Sat, 5 Dec 2015, Aradeonas wrote: Simply said: You cannot. Sure it doable. For example alternative consoles can work with mysql with help of cmd and runs cmd and then run mysql with cmd and with that they get some kind of control but I dont how to do this with Lazarus. For example if you run this without -WG command you can see that Lazarus cmd gets password message but could nopt write and it run conhost.exe. So I want to know how simulate a console. Simple Loop: - Read from program output - interpret the output and - write to program input. That's all the "general" advice we can give. Don't ever use LoadFromStream. It will try to load all data that is outputted by the program, and does not give you the possibility to write input. Michael. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Getting MySQL process output
> Simply said: You cannot. Sure it doable. For example alternative consoles can work with mysql with help of cmd and runs cmd and then run mysql with cmd and with that they get some kind of control but I dont how to do this with Lazarus. For example if you run this without -WG command you can see that Lazarus cmd gets password message but could nopt write and it run conhost.exe. So I want to know how simulate a console. Regards, Ara -- http://www.fastmail.com - Send your email first class -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Getting MySQL process output
On Sat, 5 Dec 2015, Aradeonas wrote: [Cross posted on forum so if you want answer there : http://forum.lazarus.freepascal.org/index.php/topic,30635.0.html ] Hi, I want to play with MySQL process and get what ever it write to console so I write this code: Process := TProcess.Create(nil); with Process do begin Executable := 'C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin\mysql.exe'; with Parameters do begin Options := [poUsePipes]; Add('-u'); Add('root'); Add('-p'); end; Execute; while Process.Running do Memo1.Lines.LoadFromStream(Process.Output); end; But the problem is that this will freeze because there is no output but console window write : Enter password: How can I get this in my application and all others? Simply said: You cannot. As I said I want to work with MySQL executable and read from and write in it, So I dont want to use its library or any other DB component. Specify the password on the command-line. Then maybe you can read the output, but I doubt things will work very well, since mysql uses line editing features. Michael.-- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Getting MySQL process output
[Cross posted on forum so if you want answer there : http://forum.lazarus.freepascal.org/index.php/topic,30635.0.html ] Hi, I want to play with MySQL process and get what ever it write to console so I write this code: > Process := TProcess.Create(nil); with Process do begin > Executable := 'C:\Program Files (x86)\MySQL\MySQL Server > 5.5\bin\mysql.exe'; with Parameters do begin Options := > [poUsePipes]; Add('-u'); Add('root'); Add('-p'); > end; Execute; while Process.Running do > Memo1.Lines.LoadFromStream(Process.Output); end; But the problem is that this will freeze because there is no output but console window write : > Enter password: How can I get this in my application and all others? As I said I want to work with MySQL executable and read from and write in it, So I dont want to use its library or any other DB component. Regards, Ara -- http://www.fastmail.com - Choose from over 50 domains or use your own -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus