0

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?

1 Answer 1

0

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.

so

#!/bin/bash
if test -f somefile.deb
then
    sudo dpkg -i somedebfile
else
    notify-send "somefile.deb is missing"
fi
1
  • I know, but it's something silly I want to do as a programming exercise. Nothing I would ever really use in life.
    – ebernardes
    Commented Feb 23, 2015 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .