Updates from May, 2012 Toggle Comment Threads | Keyboard Shortcuts

  • John Cartwright 4:09 PM on May 3, 2012 Permalink | Reply
    Tags: adding, cups, , ,   

    Installing printers with the CUPS web interface in Debian Linux. 

    Viewing installed printers in the CUPS administration page.

    Viewing installed printers in the CUPS administration page.

    I recently had to add a printer to my Debian System and the System Settings -> printers dialog in the Gnome 3 System Settings application would not detect my Canon MP150 printer. Therefore, I started the CUPS interface by visiting: http://localhost:631 in my web browser and I was then able to add my printer. This interface will ask for a username and password before you can go ahead, the username is “root” and the password is your root password. Then click the add printer button and you may select your printer and add it to the system. Using the CUPS interface to view your installed printers as shown in the screenshot to the left, this offers printer administration and maintenance. If you click the name of your installed printer, it will take you to a page where you may print a test page or do other maintenance tasks.

    Adding a printer with the CUPS interface.

    Adding a printer with the CUPS interface.

    This goes to show that the traditional Linux administration tools are better than the new control panels they are adding to the Linux desktop. If the Gnome 3 System Settings -> Printers dialog will not even detect my printer, what use is it? If you are wondering what version of Iceweasel I am using, it is Iceweasel 13.0 available in the Debian Experimental repositories. Ubuntu and Linux Mint would have the CUPS interface available as well. Give it a try if you are wanting to install a printer with a Linux distribution.

  • John Cartwright 2:48 PM on May 3, 2012 Permalink | Reply
    Tags: , , , , ,   

    Miscellaneous programming tricks with C. 

    This is a very simple Hello World program in C.

    int main() {
    	write(1, "Hello World\n", 14);

    Counting how long a text string is.

    #define MSG "Hello Doctor, let's get back to the TARDIS!"
    int main() {
    int g;
    g = strlen(MSG);
    if (g < 1) {
    printf("The string is not very long!\n");
    } else {
    printf("The length of the string `MSG' is: %i characters.\n", g);
    return 0;

    Code sample to check for a certain argument to a C program. using strncmp() to read from the argv[1], which is the first argument to the C program and checking if it contains the value “2”. And the value BUF sets the maximum length of the string expected.

    if (argc > 1 and strncmp(argv[1], "2", BUF) == 0) {
    	printf("\t\tRam & swap information.\n");
    	kernel("/proc/swaps", 2);
    	printf("-Uptime: ");
    	kernel("/proc/uptime", 2);
    	kernel("/proc/meminfo", 2);

    More code from my sysinfo C program that reads in files and processes them accordingly.

    #ifndef SYSINFO_H_
    #define SYSINFO_H_
    #define BUF 0x05
     * Function prototypes. Sexy... And unlike on the show `24', function
     * prototypes have nothing to to with hard disk sectors!
    void kernel(char,int);
     *  @brief  /proc file opener
     *  @param  File  An output stream.
     *  @param  len  A string length.
     *  @return  none.
     *  @pre  @a len must be a non-NULL int.
     * I hope this little function is not offending anyone. it is the only
     * way I could think to have a single function that would be able to 
     * load the different files quickly and without fuss. And it works just
     * fine, and that is what matters in the end.
    struct _kern1 {
    	char *File;
    	int len;
    	char Kyo[40];
    } *kern1 = (struct _kern1 *) 0x80;
    void kernel(const char *File, int len)
    	FILE *f;
    	char Kyo[40];
    	if (len > 10 or len < 2)
    	f = fopen(File, "r");
    	if(!f) {
    		printf ("Sorry, I cannot open: %s.\n", File);
    		printf("Please check your permissions with\n"		\
    			"your supervisor. The feature may not\n"	\
    			"be compiled and\\or enabled in your\n"		\
    			"kernel version. Or a scsi device, eg,\n"	\
    			"a USB drive may not be attached.\n");
    	} else {
    /* Based on sample code from:
     * www.koders.com/c/fid84CFEFBF311605F963CB04E0F84A2F52A8120F33.aspx
     * Specifically the section on parsing the /proc/version.
    		while (feof(f) != 1) {
    			fgets(Kyo, len, f);
    			if (strncmp(Kyo, "((", 1) == 0)
    				printf ("\n-");
    			if (strncmp(Kyo, "#", 1) == 0) {
    				printf ("\nVersion: #");
    			} else {
     * This function is fast, owing to this i feel. especially with gcc 
     * 4.3.2 & glibc 2.5+. it is faster than using: printf (Kyo);
    				fprintf (stdout, "%s", Kyo);
    #endif /* sysinfo.h */
Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc