Recent

Author Topic: How to execute Terminal command from app ?  (Read 17183 times)

Jaco

  • New Member
  • *
  • Posts: 45
How to execute Terminal command from app ?
« on: March 22, 2010, 07:19:59 pm »
Hi all,

Appreciate it if someone could help me out with the following:

I would like to execute a terminal command to unzip a zipfile, just like you do in the Terminal itself:
unzip somefile.zip -d /Tussen

Simply unzipping it by unix.shell('Open somefile.zip') will result in a created directory with the unstuffed files in it, a behaviour that I do not want.

Can this be done with a unix.shell( call? If not, any suggestions?

Thanks,

Jaco

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927

Jaco

  • New Member
  • *
  • Posts: 45
Re: How to execute Terminal command from app ?
« Reply #2 on: March 23, 2010, 07:29:25 am »
Yes, I know this page.
Might be my limitation, but still have no idea to do what I want to do.....

Jaco

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: How to execute Terminal command from app ?
« Reply #3 on: November 16, 2012, 09:51:48 pm »
You might want to use the Shell command from the Unix unit for this task.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

anis2505

  • Full Member
  • ***
  • Posts: 201
Re: How to execute Terminal command from app ?
« Reply #4 on: November 17, 2012, 05:37:07 pm »
You might want to use the Shell command from the Unix unit for this task.

WoWW  :D

You are replaying to a question of 2 and a half years old.
Dear Confucius you said {A picture is worth a thousand words}
I say {a good example is worth a thousand words}

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: How to execute Terminal command from app ?
« Reply #5 on: November 17, 2012, 06:32:45 pm »
Yes, I was aware of it.

Although I am not sure if the original poster is still interested in this issue I decided to post an answer, as others may search for a solution for the same question, and they would profit from a reply.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: How to execute Terminal command from app ?
« Reply #6 on: November 17, 2012, 07:02:47 pm »
Although I am not sure if the original poster is still interested in this issue I decided to post an answer, as others may search for a solution for the same question, and they would profit from a reply.
First port of call is always the wiki and this subject is pretty well explained over there.
The link Theo posted is all that is required.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: How to execute Terminal command from app ?
« Reply #7 on: November 17, 2012, 07:08:49 pm »
You might want to use the Shell command from the Unix unit for this task.

Hmmm... this part on the wiki page mentioned before:

http://wiki.lazarus.freepascal.org/Executing_External_Programs#Unix_fpsystem.2C_fpexecve_and_shell
Quote
Note that the 1.0.x 'Unix.Shell has been deprecated for a while, and is removed in trunk. Use fpsystem.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: How to execute Terminal command from app ?
« Reply #8 on: November 17, 2012, 08:28:47 pm »

Hmmm... this part on the wiki page mentioned before:

http://wiki.lazarus.freepascal.org/Executing_External_Programs#Unix_fpsystem.2C_fpexecve_and_shell

OK, thanks for the hint. Obviously, I have overlooked this...

The easy thing is that Shell may simply be replaced by fpSystem.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

 

TinyPortal © 2005-2018