Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

How to execute console commands from wizard?

(1/3) > >>

writser:
I just downloaded and installed Code::Blocks and so far I'm pretty impressed. I'm currently trying to write a gtk+ / gtkmm wizard to make it even better. While doing this I stumbled on a small problem. If I use `pkg-config` to setup my project, everything works like a charm. Which is terrific. However, since the include directories are not added to the project, I have no code completion. And that is unfortunately the thing I like best about Code::Blocks!

So, there is my problem. I somehow want to add the individual include directories and libraries given by pkg-config to my project. Somewhere else on the forum someone suggested to add a feature to Code::Blocks: "include output of console program". This is a possible solution, but, in my opinion, not very useful. First of all it's uses are very limited (I can only think of pkg-config) and second: it is not very flexible. Say I want to remove one library from the list? Or if pkg-config returns an error?

After some thinking I came up with the following solution. I should be able to run pkg-config IN my wizard script and store the output in a local string. Then I can extract all libraries and include directories in the wizard! If I can run console applications in my scripts, I could also use grep and sed to extract the libraries in an even easier way. I can parse the output from pkg-config to do error detection, check versions etc. etc. I'm sure there would be more uses for it. I read the Squirrel documentation and found out about the function "exec" in the standard library. This function is supposed to do exactly what I want but:

1. How do I get the output of the console command?
2. I can't include this function in my scripts. Do I have no access to the standard squirrel library?

I'm new to Code::Blocks and squirrel, so don't flame me too hard if everything I want is already possible. If this is not possible yet, please share any insights with me. Would it be useful to execute console commands from within scripts? If so, what would be the best way to do so? Is there a better way to solve my issue?

I also think I found a small issue with the wizard: http://developer.berlios.de/bugs/?func=detailbug&bug_id=9233&group_id=5358

thomas:
Hmm... I am unaware of any exec() function in squirrel, and could neither find it in the 2.1 Reference Manual nor the 2.1 Standard Library Manual... where did you find that function?
I don't think what you want to do is possible at all(although I have to admit that I don't know for sure).

Executing external programs from within scripts generally should not be possible.
Unless someone errornously added them, scripts should not have any hooks to modify the file system or executable external programs, as that may be a security risk.

writser:
The exec-function is described here: http://squirrel-lang.org/doc/sqstdlib2.html#d0e1925. However, it does say nothing about any output generated by the executed command. I agree that executing programs could cause security risks. But, do you see any other solution for my problem then? Currently I manually added the output from pkg-config to my script. Unfortunately this is not portable at all. And, as I stated above, adding `pkg-config ...` to a project is not very flexible either. I'm looking forward to your opinion.

mandrav:
The squirrel standard library is consciously not enabled, for security reasons.
Although I 'm the one who did this, I doubt we gained any security at all though :roll: ...

Game_Ender:
While pkg-config in the final build options is not best for CodeCompletion its the best solution for portability there is.  Just taking the output of pkg-config during the wizard phase makes the wizard portable but the not the resulting project file.  So I think the solution is to find a way for CodeCompletion to parse the output of pkg-config for include paths.  Tools like pkg-config are common place (see wx-config) so its not an unusual request.

Keeping the scripts sandbox only protects the user if they run untrusted wizards/configuration scripts and if the script can't already do something nasty through the CB sdk API.

Navigation

[0] Message Index

[#] Next page

Go to full version