PDA

View Full Version : Help with fopen a script(a filename.sh file)


G_P_H_M
03-25-2006, 05:25 AM
Good morning!

I have a problem with open a script file.
I have a directory named hello and it consists of 1 file jobs.sh.
I do :

if((dirp = opendir(/home/user/hello))) { //open the directory

while((dp = readdir(dirp))) {
printf("%s\n",dp->d_name);
if( (fptr = fopen("dp->d_name","r")) != NULL) {
printf("File opened\n");

} else {

printf("File couldn't be opened\n");

}

}

The pink printf outputs :
.
..
jobs.sh

Also,jobs.sh doesn't open,but why?

.
File couldn't be opened
..
File couldn't be opened
jobs.sh
File couldn't be opened

My problem is that the file jobs.sh shall open in order to read it.

Thanks,in advance!

goliatone
03-26-2006, 03:52 PM
what is that extension you are traying to open?! .sh?