Recent

Author Topic: How return a value from a Lazarus program to a bash ?  (Read 5788 times)

sinfoni

  • Jr. Member
  • **
  • Posts: 56
How return a value from a Lazarus program to a bash ?
« on: May 19, 2010, 07:22:15 am »
Hi,

Is it possible to return a value from a program called by a bash batch ?

Example:

The second line of this batch launches an interactive program where the user gives some informations.
Code: [Select]
#!/bin/bash
open -W -b com.company.MyProg
echo $?

Depending on the informations, I need to execute some other actions. For instance, in MyProg I do:
Code: [Select]
If not vl_ok then begin
    System.ExitCode:= ExitNotRegistered; // return 1
end
else begin
    System.ExitCode:= ExitOk; // returns 0
end;
Application.Terminate;

In the batch, $? always has a value of 0. That's normal because the command 'open' has been successfull. Is there any way to get the value set in MyProg ?

André

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: How return a value from a Lazarus program to a bash ?
« Reply #1 on: May 19, 2010, 07:28:52 am »
try
Code: [Select]
/program/path/MyProg
echo $?

or store the exit code in somefile.

sinfoni

  • Jr. Member
  • **
  • Posts: 56
Re: How return a value from a Lazarus program to a bash ?
« Reply #2 on: May 19, 2010, 12:49:04 pm »
I cannot just put /program/path/MyProg in my bash file because in this case, the installer failed...
(using iceberg ou pakagemaker, same issue)

The bash file is launched by the installer and it seems that the only way to launch an interactive program is using open... annoying

 

TinyPortal © 2005-2018