Issue
My system call takes an integer and returns long. I can use it in a C code like syscall(549,1)
. But I would like to use it from the terminal not from a C code. Can you please help me?
Solution
There is no way you can directly use your system call from the shell. Although, you can write a simple C program, compile it and add its location to the PATH directly or put in in /usr/local/bin. Then you will be able to call this binary directly from the shell.
The code of your C program would look something like this:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
printf("%ld\n", syscall(549, (int) strtol(argv[1], NULL, 0)));
return EXIT_SUCCESS;
}
Answered By - user8704868 Answer Checked By - David Marino (WPSolving Volunteer)