Skip to content

Instantly share code, notes, and snippets.

@jackdalton
Last active November 28, 2015 20:14
Show Gist options
  • Save jackdalton/ffe43380c369c8254694 to your computer and use it in GitHub Desktop.
Save jackdalton/ffe43380c369c8254694 to your computer and use it in GitHub Desktop.
Auto apt-get update
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *msg_usage = "Usage: agui <package1...package2> [options]";
int main(int argc, char *argv[]) {
char command[1024];
strcat(command, "apt-get update; apt-get install");
if (argc < 2) {
printf("%s\n", msg_usage);
return 0;
} else if (argc == 2) {
strcat(command, " ");
strcat(command, argv[1]);
} else if (argc > 2) {
int i;
for (i = 1; i < argc; i++) { // skip the first value
strcat(command, " ");
strcat(command, argv[i]);
}
}
system(command);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment