0

I run the 'curl' from Lazarus/FPC application using TProcess like:

proc := TProcess.Create(nil);
proc.Executable:= 'E:\sendfileemail\curl.exe';
proc.CurrentDirectory:= 'E:\sendfileemail';
proc.Parameters.Add('--upload-file d:\29\ZP_1_2019.eml --url smtps://smtp.yandex.ru:465 --ssl-reqd --mail-from xxxx@yandex.ru --mail-rcpt yyyy@yandex.ru --user zzzz@yandex.ru:password --insecure');
proc.Options := proc.Options + [poWaitOnExit, poUsePipes, poStderrToOutPut];
proc.Execute;
AStringList := TStringList.Create;
AStringList.LoadFromStream(proc.Output);
AStringList.SaveToFile('output.txt');
AStringList.Free;
proc.Free;

It's always failed with:

curl: option --upload-file d:\29\ZP_1_2019.eml: is unknown  
curl: try 'curl --help' or 'curl --manual' for more information

or whatever curl's parameter was first.
Adding each parameter separately with 'proc.Parameters.Add' doesn't matter.

At the same time

E:\sendfileemail\curl.exe --upload-file d:\29\ZP_1_2019.eml --url smtps://smtp.yandex.ru:465 --ssl-reqd --mail-from xxxx@yandex.ru --mail-rcpt yyyy@yandex.ru --user zzzz@yandex.ru:password --insecure  

executed as expected from command line manually.

ShellExecute also work.

What's wrong with running 'curl' via TProcess?

4

1 に答える 1