Recent

Author Topic: Access violation on Ubuntu  (Read 4113 times)

whoami

  • Newbie
  • Posts: 6
    • Site của tui
Access violation on Ubuntu
« on: April 25, 2017, 01:35:19 am »
I encountered an error when the program ran to the code below. I installed Lazarus 1.6.4 with 3 .deb files here https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%201.6.4/.

I also tried installing Lazarus in the Ubuntu 16.04 repository, but I have the same problem.

Quote
Access violation.

Press OK to ignore and risk data corruption.
Press Cancel to kill the program.

Code: Pascal  [Select][+][-]
  1.     AProcess := TProcess.Create(nil);
  2.     AStringList := TStringList.Create;
  3.     try
  4.       AProcess.Executable := '/bin/sh';
  5.       AProcess.Parameters.Add('-c');
  6.       //AProcess.Parameters.Add('df -h --output=source,fstype,size,used,avail,target '+GetCurrentDir);
  7.       AProcess.Options:=AProcess.Options + [poWaitOnExit];
  8.       AProcess.Execute;
  9.       AStringList.LoadFromStream(AProcess.Output);
  10.       DeviceStr := AStringList[1];
  11.     finally
  12.       AProcess.Free; AStringList.Free;
  13.     end;

Please help me. Thanks!

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Access violation on Ubuntu
« Reply #1 on: April 25, 2017, 01:51:18 am »
I encountered an error when the program ran to the code below. I installed Lazarus 1.6.4 with 3 .deb files here https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%201.6.4/.

If you think that's where the error is occurring, then set breakpoints and find the line.

Does your code actually produce anything to standard output? You have commented out the command to execute.

whoami

  • Newbie
  • Posts: 6
    • Site của tui
Re: Access violation on Ubuntu
« Reply #2 on: April 25, 2017, 01:56:56 am »
I encountered an error when the program ran to the code below. I installed Lazarus 1.6.4 with 3 .deb files here https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%201.6.4/.

If you think that's where the error is occurring, then set breakpoints and find the line.

Does your code actually produce anything to standard output? You have commented out the command to execute.

My program was already running, I tried replacing it with another command line but did not make any changes.
I'm a newbie, I've been using Delphi for a while and now I want to get acquainted with FPC to be able to compile programs on Linux.

bylaardt

  • Sr. Member
  • ****
  • Posts: 309
Re: Access violation on Ubuntu
« Reply #3 on: April 25, 2017, 02:44:07 am »
Code: Bash  [Select][+][-]
  1. /bin/sh -c
give you just a single line in return: "/bin/sh: 0: -c requires an argument"
and you are reading the second line:
Code: Pascal  [Select][+][-]
  1. DeviceStr := AStringList[1];
try this:
Code: Pascal  [Select][+][-]
  1. DeviceStr := AStringList[0];
or this:
Code: Pascal  [Select][+][-]
  1. DeviceStr := AStringList.text;

whoami

  • Newbie
  • Posts: 6
    • Site của tui
Re: Access violation on Ubuntu
« Reply #4 on: April 25, 2017, 03:22:22 am »
I have switched to another method. Thank you all.

 

TinyPortal © 2005-2018