Code:
if (optind < argc) {
strcpy(BIN_FILE,argv[optind++]);
//make sure the executable exists
rc=access( BIN_FILE, F_OK );
if (( rc == -1 )) {
rc = errno;
myprintf("Value of errno: %d\n", errno);
myprintf("Error opening file: %s\n", strerror( rc ));
myprintf("%s\n", BIN_FILE);
exit(AR_EXIT_FAILURE);
}
//Separate the filename and dirname C is unbelievable a simple dirname/basename call destroying its in therefor forcing us to make a duplicate first :-(
char *dirc, *basec;
dirc = strdup(BIN_FILE);
basec = strdup(BIN_FILE);
strcpy(BIN_FILE_DIR,dirname( dirc ));
strcpy(BIN_FILE_NAME,basename( basec ));
}
Note that it worked when I'm just running the binary.
When I'm calling it from script.sh it dont works.