Example script
#!/usr/bin/cscript -lm
#include <stdio.h>
#include <math.h>
int main(int num, char *opts[])
{
printf("Hi from stu.\n");
printf("These are the params I got:\n");
int lp;
for (lp = 0; lp < num; lp++)
{
printf ("param (%d) #%d: %s\n", (int)exp2(lp), lp, opts[lp]);
}
return 0;
}
If you use functions that aren't in libc you can add -l on the she-bang line to include the library in the precompile step. In test.c I use the exp2 function which is in libm.
If you need to pass parameters to your script that shouldn't get picked up by the cscript process you can use the -- flag.
./test.c -lm -- --flag-for-script
output:
Hi from stu.
These are the params I got:
param (1) #0: ./test.c
param (2) #1: --flag-for-script
In that example -lm is passed to cscript for precompiling, and --flag-for-script is passed to the script, you can see the script picked it up as its first parameter.
Previous page: Download
Next page: Requirements