![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How ls | wc -l works? | krishmaths | UNIX for Dummies Questions & Answers | 3 | 04-11-2008 01:16 PM |
| Works with FTP but not NFS | pbonilla | UNIX for Dummies Questions & Answers | 1 | 01-08-2008 02:31 PM |
| How the for loop works? | neelaksh | UNIX for Dummies Questions & Answers | 6 | 02-04-2007 10:42 AM |
| Code works sometimes and sometimes not | hp-aix-lnx-user | Shell Programming and Scripting | 2 | 04-06-2006 08:43 AM |
| how sendmail works | alzep | UNIX for Dummies Questions & Answers | 3 | 02-18-2004 01:33 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Works from console but not when clicked in KDE
why is it that:
#include <sys/stat.h> #include <stdio.h> int main(int argc, char **argv) { mkdir("testDir", S_IRUSR|S_IWUSR|S_IXUSR); return 0; } works from the console when i type ./a.out but when clicked on from a window manager, it does diddly squat??? Interested to hear your answers. Regards, Jason. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
My guess would be that it worked but you don't know where it worked. Or that it failed because testDir already exists.
But why guess? You are susposed to check the return code from a system call. If the system call fails, you will get -1 and errno will be set to a value describing what went wrong. You should put code in your program to display the error code. |
|
#3
|
|||
|
|||
|
1. What is the current directory when the program runs?
2. write a syslog or /tmp/myerror.log from the program to say what happened 3. try "perror()" as in if (mkdir(.....)) { perror("mkdir failed\n"); exit(1); } |
|
#4
|
|||
|
|||
|
Quote:
Quote:
(just to clear things up, I am totally new to system programming being a java programmer... I have dabbled in Fortran but wanted to tackle Unix and C so here I am slaving away with a really really thick book... :-) Thanks for your patience.) So my next question is: Why on earth does it begin executing from home when it's clicked from another directory? Seems like a weird thing to do. Is their a function that can test where it was clicked from and to then change to that dir so it is now current? You guys have been very helpful. Thanks. Jason. |
|
#5
|
|||
|
|||
|
Quote:
|
|
#6
|
|||
|
|||
|
Quote:
NB: UNIX programs by themselves know *nothing* about KDE. I suggest you look at what you are trying to do and work out is creating a directory in the same directory as the program a good idea? Unix programs normally separate out code from config from data. You also need to deal with multiuser issues, what happens if two people run the program at exactly the same time? If this is supposed to be a temporary directory why not create it in /tmp, /usr/tmp or $TMP ? |
|
#7
|
|||
|
|||
|
Quote:
Seeing as I am not anywhere near that level yet to even begin thinking of these matters or working on my app I am writing no-brainers to learn how functions for the Unix environment work. Still leaves me with the problem of determining where the program is actually located so I could read in config files... :-( I have used make and make install for other programs before. Can one rely on the installation directory being constant on all Unix systems should make be used? If so I'll find some stuff to read up on it. That way I could hard code the installation directory into the app... Much to learn... :-| I sense some frustration in your last post, sorry if these noob questions are getting on your nerves. If you have any tutorials on say program design in the Unix environment, you can post them I'll read them to hopefully ask more sensible questions. Cheers Jason. |
|||
| Google The UNIX and Linux Forums |