[SATLUG] Cron Weekly site

Christopher christopher.lemire at gmail.com
Fri Jun 17 01:30:06 CDT 2016


This bit of code I did, two implementations, call either function, and
you have a progress bar.

#include <stdio.h>
#include <unistd.h>

void array_spinner();
void ptr_spinner();

enum bool {FALSE, TRUE};

int main() {
    ptr_spinner();
    printf("\n");

    return TRUE;
}

void ptr_spinner() {
    char *spinner = "\\|/-";
    int i = 0,c;

    for(c = 0;c < 500;c++) {
        if(i == 4) {
            i = 0;
        }
        printf(".%c\b", *(spinner + i++));
        fflush(stdout);
        usleep(100000);
    }
}

void array_spinner() {
    int pos;
    while(pos < 500) {
        pos = 0; // reset to 0
        char cursor[4] = { '/', '-', '\\', '|' };
        printf ("%c\b", cursor[pos]);
        fflush (stdout);
        pos = (pos + 1) % 4;
        usleep (100000);
    }
}
Christopher Lemire


On Wed, Jun 15, 2016 at 6:16 PM, Craig <sargonemail at gmail.com> wrote:
> The weekly newsletter for Linux and Open Source Administrators (
> https://www.cronweekly.com/archives/ ) has some
> interesting links to information and scripts that might be of use/interest
> to users of this group.
> e.g.  scripting a % done for the copy command :
> https://chris-lamb.co.uk/posts/can-you-get-cp-to-give-a-progress-bar-like-wget
>
> Craig
> --
> _______________________________________________
> SATLUG mailing list
> SATLUG at satlug.org
> http://alamo.satlug.org/mailman/listinfo/satlug to manage/unsubscribe
> Powered by Rackspace (www.rackspace.com)


More information about the SATLUG mailing list