473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Help with scripts .sh files

Good morning!

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!
Mar 25 '06 #1
0 5593

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Rob Long | last post by:
Hey, I've written a custom HTML library using many PHP scripts as seperate files (just like I'd do a java project) and I'm having some problems where I'm including scripts in different...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
4
by: Jm | last post by:
I'm trying to set up ASP.NET on my Windows 2000 server w/ IIS 5 and MS ISA Server. Here's what I have done so far without any luck. Here's the results from the pages I've created...
1
by: treelife | last post by:
I'm getting and internal server error when | run the following mod_python script. I am actually trying to run Django. Script: from mod_python import apache def handler(req):...
37
by: John Salerno | last post by:
I contacted my domain host about how Python is implemented on their server, and got this response: ------------------- Hello John, Please be informed that the implementation of python in our...
17
by: Saps | last post by:
Hi all. Can anyone help me here. I have loads of .sql files and i need a way to call these from my asp page so the user can run them from the browser. Meaning i have a page with a list of all...
3
by: simonharrison | last post by:
Hello everyone. Hopefully someone can point me in the right direction here. I'm wanting to write a script to open microsoft word and adobe pdf documents . Here is a little background: At the...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: wb5plj | last post by:
Hi I am having a problem passing some sql to the db2cmd via ant. This is very confusing as I am doing this exact thing elseware with no problem (just differant sql, and I have verified the sql is...
0
alpnz
by: alpnz | last post by:
I keep getting an error on the windows login of the following script. Any ideas anyone? #!/bin/sh #A script to move files across a network, which has strict firewalling, and only one gateway...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.