Re: [lazarus] TProcess.Input problem
Malcolm Poole schreef: Henry Vermaak wrote: On 29/11/2007, Vincent Snijders [EMAIL PROTECTED] wrote: Maybe you can use dar_slave instead? http://dar.linux.free.fr/doc/man/dar_slave.html I'll have to reread the docs for dar-slave again: I don't think I fully grasped its relationship to dar. To me it seemed dar-slave is the backend doing all the work. dar is just the terminal front end, just like you are making a gui front end. Vincent _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] TProcess.Input problem
Hello everyone! I am trying to write a front-end for the command-line archiving program dar ( http://dar.linux.free.fr/ ) I can read happily from the dar Process.Output but am not managing to respond using Process.Input When extracting an archive using the commandline, when dar finds a file to be overwritten, it asks if it should be overwritten, to which the response is [RETURN] key for 'Yes' or [ESC] key for 'NO'. I have tried writing both #13 and #27 to Process.Input but it has no effect: the program just hangs as the Process never stops running and gives no more output. The relevant bit of code is given below. Can anyone suggest what the problem could be? Malcolm Using fpc 2.2.0 and Lazarus 0.9.24 on Linux: Proc.Options := [poUsePipes, poStdErrToOutput] while i = Count do begin if (StdOutBuf[i] in [#10,#13]) or (i = Count) then begin OutputLine := copy(StdOutBuf, LineStart, i-LineStart); if Pos('is about to be over', OutputLine) 0 then case MessageDlg('Confirm overwrite file', 'Overwrite ' + Copy(OutputLine, 1, Pos('is about to be over', OutputLine)-2), mtConfirmation, [mbYes, mbNo, mbCancel], 0) of mrYes: begin SetLength(StdInBuf, 1); StdInBuf[1] := CHR(VK_RETURN); writeln('Bytes sent ',Proc.Input.Write(StdInBuf[1], Length(StdInBuf))); end; mrNo: begin SetLength(StdInBuf, 1); StdInBuf[1] := CHR(VK_ESCAPE); writeln('Bytes sent ',Proc.Input.Write(StdInBuf[1], Length(StdInBuf))); end; mrCancel: Proc.Terminate(0); // this option works: Proc terminates and the app continues normally end; if OutputLine '' then MessageMemo.Lines.Add(OutputLine); OutputLine := ''; if (iCount) and (StdOutBuf[i+1] in [#10,#13]) and (StdOutBuf[i]StdOutBuf[i+1]) then Inc(i); LineStart := i+1; Application.ProcessMessages; end; Inc(i); end; _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] TProcess.Input problem
Malcolm Poole wrote: Hello everyone! I am trying to write a front-end for the command-line archiving program dar ( http://dar.linux.free.fr/ ) I can read happily from the dar Process.Output but am not managing to respond using Process.Input When extracting an archive using the commandline, when dar finds a file to be overwritten, it asks if it should be overwritten, to which the response is [RETURN] key for 'Yes' or [ESC] key for 'NO'. I have tried writing both #13 and #27 to Process.Input but it has no effect: the program just hangs as the Process never stops running and gives no more output. Try writing #10 or #13#10 Marc _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] TProcess.Input problem
Marc Weustink wrote: Malcolm Poole wrote: Hello everyone! I am trying to write a front-end for the command-line archiving program dar ( http://dar.linux.free.fr/ ) I can read happily from the dar Process.Output but am not managing to respond using Process.Input When extracting an archive using the commandline, when dar finds a file to be overwritten, it asks if it should be overwritten, to which the response is [RETURN] key for 'Yes' or [ESC] key for 'NO'. I have tried writing both #13 and #27 to Process.Input but it has no effect: the program just hangs as the Process never stops running and gives no more output. Try writing #10 or #13#10 Marc No, I've already tried that, and checked the dar source: it is definitely looking for one byte of input: #27 or '/n', which is #13. Is it possible that it is ignoring stdin because it is not being run from a terminal? Malcolm _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] TProcess.Input problem
Malcolm Poole wrote: Marc Weustink wrote: Malcolm Poole wrote: Hello everyone! I am trying to write a front-end for the command-line archiving program dar ( http://dar.linux.free.fr/ ) I can read happily from the dar Process.Output but am not managing to respond using Process.Input When extracting an archive using the commandline, when dar finds a file to be overwritten, it asks if it should be overwritten, to which the response is [RETURN] key for 'Yes' or [ESC] key for 'NO'. I have tried writing both #13 and #27 to Process.Input but it has no effect: the program just hangs as the Process never stops running and gives no more output. Try writing #10 or #13#10 Marc No, I've already tried that, and checked the dar source: it is definitely looking for one byte of input: #27 or '/n', which is #13. are you sure that it is #13 and not #10 ? IIRC newlines on unix are #10 Is it possible that it is ignoring stdin because it is not being run from a terminal? Thats possible too. But maybe it isn't reading stdin at all. Marc _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] TProcess.Input problem
Marc Weustink wrote: Malcolm Poole wrote: Marc Weustink wrote: Malcolm Poole wrote: Hello everyone! I am trying to write a front-end for the command-line archiving program dar ( http://dar.linux.free.fr/ ) I can read happily from the dar Process.Output but am not managing to respond using Process.Input When extracting an archive using the commandline, when dar finds a file to be overwritten, it asks if it should be overwritten, to which the response is [RETURN] key for 'Yes' or [ESC] key for 'NO'. I have tried writing both #13 and #27 to Process.Input but it has no effect: the program just hangs as the Process never stops running and gives no more output. Try writing #10 or #13#10 Marc No, I've already tried that, and checked the dar source: it is definitely looking for one byte of input: #27 or '/n', which is #13. IIRC newlines on unix are #10 This is true, but unfortunately not the solution Is it possible that it is ignoring stdin because it is not being run from a terminal? Thats possible too. But maybe it isn't reading stdin at all. I was beginning to suspect that this was possible (*sighs*). Looking again at the dar source I found the following: // we do not use anymore standart input but open a new descriptor // from the controlling terminal. This allow in some case to keep use // standart input for piping data while still having user interaction // possible. Apart from the fact that it doesn't use stdin for interaction I'm afraid this is all a bit above me. I suspect that this means that I am not going to be able to interact with dar using TProcess. Is this correct? Thanks for your help, Marc Malcolm _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] TProcess.Input problem
On Thu, 29 Nov 2007, Malcolm Poole wrote: Marc Weustink wrote: Malcolm Poole wrote: Marc Weustink wrote: Malcolm Poole wrote: Hello everyone! I am trying to write a front-end for the command-line archiving program dar ( http://dar.linux.free.fr/ ) I can read happily from the dar Process.Output but am not managing to respond using Process.Input When extracting an archive using the commandline, when dar finds a file to be overwritten, it asks if it should be overwritten, to which the response is [RETURN] key for 'Yes' or [ESC] key for 'NO'. I have tried writing both #13 and #27 to Process.Input but it has no effect: the program just hangs as the Process never stops running and gives no more output. Try writing #10 or #13#10 Marc No, I've already tried that, and checked the dar source: it is definitely looking for one byte of input: #27 or '/n', which is #13. IIRC newlines on unix are #10 This is true, but unfortunately not the solution Is it possible that it is ignoring stdin because it is not being run from a terminal? Thats possible too. But maybe it isn't reading stdin at all. I was beginning to suspect that this was possible (*sighs*). Looking again at the dar source I found the following: // we do not use anymore standart input but open a new descriptor // from the controlling terminal. This allow in some case to keep use // standart input for piping data while still having user interaction // possible. Apart from the fact that it doesn't use stdin for interaction I'm afraid this is all a bit above me. I suspect that this means that I am not going to be able to interact with dar using TProcess. Is this correct? This is correct. If it uses accesses the terminal directly, there is little you can do, except opening the terminal and trying to control it yourself, but that's outside the scope of TProcess. Michael. _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] TProcess.Input problem
Michael Van Canneyt schreef: On Thu, 29 Nov 2007, Malcolm Poole wrote: Marc Weustink wrote: Malcolm Poole wrote: Hello everyone! I am trying to write a front-end for the command-line archiving program dar ( http://dar.linux.free.fr/ ) Is it possible that it is ignoring stdin because it is not being run from a terminal? Thats possible too. But maybe it isn't reading stdin at all. I was beginning to suspect that this was possible (*sighs*). Looking again at the dar source I found the following: // we do not use anymore standart input but open a new descriptor // from the controlling terminal. This allow in some case to keep use // standart input for piping data while still having user interaction // possible. Apart from the fact that it doesn't use stdin for interaction I'm afraid this is all a bit above me. I suspect that this means that I am not going to be able to interact with dar using TProcess. Is this correct? This is correct. If it uses accesses the terminal directly, there is little you can do, except opening the terminal and trying to control it yourself, but that's outside the scope of TProcess. Maybe you can use dar_slave instead? http://dar.linux.free.fr/doc/man/dar_slave.html Vincent _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] TProcess.Input problem
Vincent Snijders wrote: Michael Van Canneyt schreef: On Thu, 29 Nov 2007, Malcolm Poole wrote: Marc Weustink wrote: Malcolm Poole wrote: Hello everyone! I am trying to write a front-end for the command-line archiving program dar ( http://dar.linux.free.fr/ ) Is it possible that it is ignoring stdin because it is not being run from a terminal? Thats possible too. But maybe it isn't reading stdin at all. I was beginning to suspect that this was possible (*sighs*). Looking again at the dar source I found the following: // we do not use anymore standart input but open a new descriptor // from the controlling terminal. This allow in some case to keep use // standart input for piping data while still having user interaction // possible. Apart from the fact that it doesn't use stdin for interaction I'm afraid this is all a bit above me. I suspect that this means that I am not going to be able to interact with dar using TProcess. Is this correct? This is correct. If it uses accesses the terminal directly, there is little you can do, except opening the terminal and trying to control it yourself, but that's outside the scope of TProcess. Maybe you can use dar_slave instead? http://dar.linux.free.fr/doc/man/dar_slave.html from the manpage I guess dar_slave communicates through named pipe. This should be possible through tprocess too. Marc _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] TProcess.Input problem
On 29/11/2007, Vincent Snijders [EMAIL PROTECTED] wrote: Maybe you can use dar_slave instead? http://dar.linux.free.fr/doc/man/dar_slave.html use libdar, i'd say. but bindings need to be created from the c++. Vincent henry _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] TProcess.Input problem
Henry Vermaak wrote: On 29/11/2007, Vincent Snijders [EMAIL PROTECTED] wrote: Maybe you can use dar_slave instead? http://dar.linux.free.fr/doc/man/dar_slave.html I'll have to reread the docs for dar-slave again: I don't think I fully grasped its relationship to dar. use libdar, i'd say. but bindings need to be created from the c++. Yes, I've no idea how to relate Pascal and c++ though. I looked at the C bindings, but they are so thoroughly documented that I could hardly see the code for the documentation :-D . I've thought of a workaround for overwriting files using only dar, but I think I may need to scale down my app a bit to avoid situations where dar asks for input. What puzzles me is why it freezes my app when it's waiting for input. I suspect it happens when the loop returns to the top at while Proc.Running and is unable to interrogate the TProcess. Many thanks for your input anyway, folks. Malcolm _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] TProcess.Input problem
Am Donnerstag, den 29.11.2007, 23:27 + schrieb Malcolm Poole: I've thought of a workaround for overwriting files using only dar, but I think I may need to scale down my app a bit to avoid situations where dar asks for input. This would be best, you could integrate anything necessary in the gui. What puzzles me is why it freezes my app when it's waiting for input. I suspect it happens when the loop returns to the top at while Proc.Running and is unable to interrogate the TProcess. I think looking at dars source at the spot where it opens the channel for asking the user might help you. Since it is not stdin it mustbe some other file that may be catchable. HTH, Marc _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives