Raspberry Pi system command.

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

mnf
Valued Contributor
Valued Contributor
Posts: 482
Joined: Wed May 31, 2017 11:57 am
Has thanked: 52 times
Been thanked: 267 times
Contact:

Raspberry Pi system command.

Postby mnf » Sat Oct 06, 2018 9:00 am

One for Raspberry Pi users:

Was thinking about unzipping a file on the Pi - using Flowcode.. That would be a big project and madness unless you had )a lots of time and b) someone was paying big bucks and c) lots of (hard) work.

So the easy way is to use someone else's code. The good news is that this is straightforward.

Use the 'system' command in a C macro.

So for example:

Code: Select all

system("mkdir test");      // Create a new directory 'test'


or

Code: Select all

system("gunzip file.gz");   // Unzip file.gz


This only works for Pi users (at present) - where the underlying OS has commands available. To make things more general - build and use a string variable and then: (take a peek at the C code to get the variable names FC has used)

Code: Select all

system(FCV_S);   // Use global string S as a command....


Martin
These users thanked the author mnf for the post:
Benj (Tue Oct 09, 2018 10:59 am)
Rating: 5.56%