Recent

Author Topic: CommandLine is deprecated - shell operators |  (Read 15783 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: CommandLine is deprecated - shell operators |
« Reply #15 on: February 23, 2014, 07:26:31 pm »
Si le message du compilateur t'ennuie, tu peux utiliser ceci :

Code: [Select]
{$WARN SYMBOL_DEPRECATED OFF}
    VProcess.CommandLine := ACommandLine;
{$WARN SYMBOL_DEPRECATED ON}

Translate : If the compiler-message borow you, you can add this in your code .
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7493
Re: CommandLine is deprecated - shell operators |
« Reply #16 on: February 23, 2014, 08:13:59 pm »
I do use only  "CommandLine". Too many problems with Parameters.Add.

What are the bugreports for that? I'm not aware of any problems. (that commandline doesn't have)
Yes, shellexecute can do things you can't do with parameters.add, but you can't do them with .commandline either.

The problem is that commandline must be parsed into parameters before handing it to the system.
In general .commandline roughly works, but won't get any new "quoting" related fixes.

The following quick test prints the model here:


uses Process,sysutils;

var  xx : array[0..1000000] of char;

   process1:TProcess;
   aread,aout:integer;
begin
 process1:=tprocess.create(nil);
 Process1.Options := [poUsePipes,poStderrToOutPut];
 Process1.Executable := '/bin/bash';
 Process1.Parameters.Add('-c');
 Process1.Parameters.Add('cat /proc/cpuinfo | grep model | cut -c14-');
 Process1.Execute;
 sleep (10);
 AOut := Process1.Output.NumBytesAvailable;
 writeln(aout);
 ARead := Process1.Output.Read(xx, high(xx));
 writeln(xx);
end.


« Last Edit: February 23, 2014, 08:23:03 pm by marcov »

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: CommandLine is deprecated - shell operators |
« Reply #17 on: February 23, 2014, 10:55:09 pm »
@ Marcov :
Quote
The following quick test prints the model here:

Hum, indeed and nice.  :-[

Quote
What are the bugreports for that?

Maybe (surely) i was too lazy to do it work with Parameters.Add (it never works likes i wanted) and
"CommandLine" does always perfectly his job, a simpler way... :-X
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs