tags:

views:

65

answers:

5
A: 

You could see how other people do it. Looks like you're trying to create something similar to Synaptic, you may check in their source.

Dmitry Yudakov
not anything near as complicated. If anything I'd like to pipe commands to synaptic.
Blackbinary
+4  A: 

If you use the traditional C standard lib, you can choose from:

  • popen() - Opens a process with stdio IO streams to read/write to the process
  • system() - Executes a process with same IO streams as parent

or:

  • fork() + execl() (or exec variants) which is essentially how system() is implemented.

Try the man pages on all of these.

Also, order "Advanced Programming in the UNIX Environment" by W. Richard Stevens

mrjoltcola
Maybe you wanted a line break before 'system()...' ?
Eric Seppanen
Thanks, all i was looking for is `system("sudo apt-get install <x>");`I dont know why others seemed to think this was a hard task.
Blackbinary
@Blackbinary: Because `system()` won't let the initiating process do much by way of keeping track of how the external command goes. If that's OK with you, good. If not there is `popen()`, and if that is not enough you'll find yourself deep in the unix internals: managing signals and IPC and and and...
dmckee
@dmckee in this case, the user sees the terminal output of the command. So if there is any error, it is displayed. Thus system() is just fine.
Blackbinary
A: 

You are attempting to (1) do command line parsing and (2) perform an installation of software. You should know that apt-get is a significant undertaking.

Paul Nathan
A: 

The portable way to do this is with system(). The way that's less portable, but more flexible would be to use fork() followed by exec(). There is also popen, if you need/want to communicate with the child via its stdin or stdout (e.g., if you want to capture its output and display it in a window).

Jerry Coffin
A: 

If using C is not a must, you can try coding in Python(Perl). You will greatly reduce development time, and you can use GUI modules like tkinter(Python) or Tk(Perl) etc that are easy to use. you will have your GUI up in no time.

using c and gtk+ the gui isn't the issue.
Blackbinary