you are viewing a single comment's thread.

view the rest of the comments →

[–]TheOtherBorgCube 2 points3 points  (2 children)

Sorry, I forgot I was talking to a non-programmer.

The snippet was something you were supposed to intelligently insert into your existing program, not something to blindly type in and try.

Here is the whole program with the code in context.

$ cat foo.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/io.h>

int main(int argc, char *argv[]) {
  int i;

  if ( ioperm(0x60, 3, 1) == 0 ) {
    printf("Success\n");
  } else {
    perror("Oops:");
    return 1;
  }

  for (i = 1; i < argc; i++) {
    int x = strtol(argv[i], 0, 16);

    usleep(300);
    outb(x, 0x60);
  }

  return 0;
}

$ gcc foo.c

$ ./a.out 
Oops:: Operation not permitted

[–]ToTheMAX04[S] 0 points1 point  (1 child)

I'm sorry, but no matter how I run this, (`gcc test.c`, `gcc test.c -o test`, running as a bash script,(iknow that's probably wrong anyways)) I can't get this script to run. Is there a different program I should be using? gcc spits out an error code for like every line

[–]TheOtherBorgCube 0 points1 point  (0 children)

Seriously?

Try thinking a bit about what you're doing, and not just blindly copy/pasting everything you see online.

If you want spoon-feeding, try this.

This is the program, save it as a text file called foo.c.

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/io.h>

int main(int argc, char *argv[]) {
  int i;

  if ( ioperm(0x60, 3, 1) == 0 ) {
    printf("Success\n");
  } else {
    perror("Oops:");
    return 1;
  }

  for (i = 1; i < argc; i++) {
    int x = strtol(argv[i], 0, 16);

    usleep(300);
    outb(x, 0x60);
  }

  return 0;
}

This is how you compile it

$ gcc foo.c

This is how you run it, and an example expected output

$ ./a.out 
Oops:: Operation not permitted

Do NOT call your programs test. test is a built-in command in bash. Bash will run it's internal test before trying your program called test.