noob error quesion


 
Thread Tools Search this Thread
Top Forums Programming noob error quesion
# 1  
Old 04-11-2011
noob error quesion

Hey, I a newbie in unix programming.

I type the following command
if ((configfd = open(CONFIGFILE, O_CREAT | O_WRONLY)) == -1)

and the result I get from open is -1, which means error.
how can I figure out the cause of the error ?
# 2  
Old 04-11-2011
Means that your program can not create a file specified in CONFIGFILE. Use perror to see why.

Code:
 
sprintf(buf, "open failed: %s", CONFIGFILE);
perror(buf);

# 3  
Old 04-12-2011
Thanks a lot.
that's exactly what I was looking for.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron-Noob

Hi guys! Consider the following PERL script, #!/usr/bin/perl my $userID = `whoami`; open(TMP, ">user.txt"); print TMP "$userID"; close(TMP); Run on the command line it works no problem. Run using crontab it doesn't work. Where do I go to check errors from crontab? I've read things... (25 Replies)
Discussion started by: Jaymoney
25 Replies

2. HP-UX

Anybody wants to help a complete Noob?

Hello there, first post here so go easy on me! :D I just aquired an old HP 9000 Dclass d220 server, all I know is that it's running HP-UX, and it appears to boot fine (I see the modules loading, etc..) Now, I have been an MS guy all my life (yeah I know, make fun of me), so I really have no... (9 Replies)
Discussion started by: Marvio
9 Replies

3. Shell Programming and Scripting

Noob: Syntax error near unexpected token 'else'

Hi guys, Completely new to all this and finding it soooooooo hard. Any help appreciated. The idea is to check a list of .conf files and maintain a hash, if it does not match its hash it needs to do some more stuff, but I can't even get this first bit sorted... No idea if any of this is right.... (5 Replies)
Discussion started by: Jandiedonkerman
5 Replies

4. Shell Programming and Scripting

I suspect a simple quesion

I bet this is really simple but I can only find silly long solutions. Im trying to read the second word of each line in a file and pipe it out, in Win32 it looks something like: for /F "tokens=2" %%b in (file.txt) do etc.. Sorry for the probably dumbass question! (1 Reply)
Discussion started by: joe19oo.c
1 Replies

5. Shell Programming and Scripting

another quesion to merge file

hi experts yesterday, I asked a question that is very like today's quesion, I think this one will be more difficult than yesterday, I really want to get the answer so I post here again file1 arch : x86 install : pass make os : pass make build kernel : pass=100 failed=45 ... (0 Replies)
Discussion started by: yanglei_fage
0 Replies

6. Solaris

xterm quesion

Can we throw a window from solaris to Linux redhat? (1 Reply)
Discussion started by: mokkan
1 Replies

7. Linux

noob help needed

i'm having trouble putting together a program :( any help would be much appreciated! Write a Shell Program to automate the process of collecting assignments from the directories of students of any specified class. The person running the program should be able to pass a parameter to the... (1 Reply)
Discussion started by: ace_face
1 Replies

8. UNIX for Dummies Questions & Answers

FreeBSD filesystem is full error by Noob

Hello, Max here, I have installed FreeBSD on a compaq Intel box an have filesystem problems. I am now on install number 3 and encounter the same error. This time after DL the ports list and DL a number of programs the DL stopped and I got an error message that the filesystem is full I am looking... (6 Replies)
Discussion started by: madMax8911
6 Replies

9. Solaris

pam module quesion

quick question about PAM module. Here may pam.conf file. How do I verify that pam modules work correctly? Does it mean when it run cron job, it checks the pam module for authentication? Thanks in advance. # passwd auth required pam_passwd_auth.so.1 # # cron service (explicit... (0 Replies)
Discussion started by: mokkan
0 Replies

10. UNIX for Dummies Questions & Answers

Another "green horn" quesion.

I have read this thread : http://forums.unix.com/showthread.php?threadid=75 Which was very informative, but I still have a question or two. I am getting ready to put a box together and put UNIX on it so when I buy the first two books listed I can start practicing. That said, what version of... (2 Replies)
Discussion started by: ICE
2 Replies
Login or Register to Ask a Question