I'm interested in writing a program that I can use to run shabang scripts.
Here is the program, /home/joe/main.c:
Code:
int main(int argc, char** argv) {
char blah[256];
if (argc > 0) {
printf("cmd: %s\n", argv[0]);
}
scanf("%s", blah);
printf("stdin: %s\n", blah);
}
I compile it with "gcc -o /home/joe/main /home/joe/main.c".
Here's the script, /home/joe/tryme:
Code:
#!/home/joe/main
hubba hubba
But when I run /home/joe/tryme, it doesn't read the file into stdin (that was my guess), but instead waits for stdin from the prompt (i.e., exact same behavior as I get when running /home/joe/main).
I tried Googling for answers, but all I get (unsurprisingly) is material on the scripting side of things, not on the programming side. How do these scripts work, exactly? Thanks in advance.