I don't care if this is unsafe, because I'm only doing it as a programming exercise, but that's what I want to do:

I want to create a C program that, with the "system" command, will call dpkg and install some .deb files.

But, I want it to use something like gksu to ask for the password outside of the command line environment.

So, basically, I will double click my program and it will do for me:

  1. Check if the .deb files are present
  2. If not, use notify-send to tell the user there's a file missing
  3. If they are all present, call a "gksu dpkg" thing to install the packages and use notify-send to tell when the packages are installed.

How can I do it?


I wouldn't use gksu for command-line/terminal operations, gksu is a "GTK+ frontend for su and sudo", why not just use sudo directly?

Bash script would work easily on the command line. See man bash for info like

test: test [expr]
Evaluate conditional expression.
-e FILE True if file exists.
-f FILE True if file exists and is a regular file.


if test -f somefile.deb
    sudo dpkg -i somedebfile
    notify-send "somefile.deb is missing"
| improve this answer | |
  • I know, but it's something silly I want to do as a programming exercise. Nothing I would ever really use in life. – ebernardes Feb 23 '15 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.