|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Opening a Script file
Hi Everyone!
I have a difficulty in openning an .sh file,Here is my code (hello directory consists of one file jobs.sh) struct dirent *dp; DIR *dirp; int fd; pid_t id; if((dirp = opendir(/home/user/hello))) { //open the directory while((dp = readdir(dirp))) { printf("%s\n",dp->d_name); //It outputs //. //.. //jobs.sh //Afterwards,the program cannot open any file and the output is //. //File couldn't be opened //.. //File couldn't be opened //jobs.sh //File couldn't be opened if( (fd = open("dp->d_name",O_RDONLY)) != -1) { printf("File opened\n"); id = (pid_t)atoi(dp->d_name); printf("%d\n",id); } else { printf("File couldn't be opened\n"); } } I dunno what i have done wrong,I'm sure about the path of the directory cause inside the directory i have typed the pwd command,also the file has 700 permission and the perror message is that it doesn't exist. Could you please help me? i would like to ask you sthg else,as well! Every script when it is executed has a number which is the process ID of the script.How do i find this ID?I mean which function shall i use in order to find it? Thanks,in advance! |
![]() |
| Viewing: Dev Shed Forums > Web Site Management > Scripts > Opening a Script file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|