[fpc-pascal] TProcess.CommandLine > 255 fails

T.Guilleminot tom at guilleminot.org
Sun Jan 4 12:31:18 CET 2009


> Please provide a compilable program that demonstrates the problem.
> Jonas



Create a myini.ini file containing :

[TEST] 
CMD_OK=echo 'Hello !'
CMD_NOT_OK=mencoder dvb://M6 -sws 9 -of lavf -lavfopts format=mp4 -vf 
scale=480:320,dsize=480:320,harddup -ovc x264 -x264encopts 
bitrate=500:vbv_maxrate=1500:vbv_bufsize=2000:nocabac:me=umh:trellis=1:level_idc=30:global_header:threads=2:pass=1:turbo 
-oac faac -faacopts mpeg=4:object=2:br=160:raw -channels 2 -srate 48000 
-o test.mp4


Then the program :

program Pb_TProcess_255;

uses Process, inifiles;

var
  Ini_File : TIniFile;
  CMD_OK, CMD_NOT_OK : ansistring;

// Read INI File
Procedure Read_Parameters_File;
begin
  Ini_File := TIniFile.Create('./myini.ini');

  with Ini_File do begin
    CMD_OK:=ReadString('TEST', 'CMD_OK', 'error');
    CMD_NOT_OK:=ReadString('TEST', 'CMD_NOT_OK', 'error');
        writeln;
    writeln(' CMD_OK : '+CMD_OK);
    writeln;
        writeln(' CMD_NOT_OK : '+CMD_NOT_OK);
        writeln;
  end;
end;

// Run an OS Command and *Wait* his Completion to Continue
procedure Run_Command_Wait(TheCommand : string); cdecl;
var
  AProcess: TProcess;
Begin
  AProcess := TProcess.Create(nil);
  AProcess.CommandLine := TheCommand;
  AProcess.Options := AProcess.Options+ [poWaitOnExit];
  AProcess.Execute;
  AProcess.Free;
end;

// Main Program
begin
  Read_Parameters_File;
    Run_Command_Wait(CMD_OK);
    writeln;
    Run_Command_Wait(CMD_NOT_OK);
end.


The first command runs OK but the 2nd one reports an error and shows the 
255th character :

Hello !

MEncoder 2:1.0~rc2-0ubuntu17 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 CPU          6600  @ 2.40GHz (Family: 6, Model: 
15, Stepping: 6)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
-faaco is not an MEncoder option
Exiting... (error parsing command line)

THanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20090104/06d533a5/attachment.html>


More information about the fpc-pascal mailing list