I've googled and searched, but can't find an answer to my first post here.

Using FreeBSD v7.0, I wrote a simple test program in c that just outputs a few lines of text to the screen. I discovered that the program apparently cannot be run from within the same directory where it resides. So, I moved it to /usr/local/bin, and now can execute it from my home directory.

I'm using the JWM window manager, and put my c program into the JWM menu, but it won't execute from there. Both JWM and the program reside in /usr/local/bin.

I'd like to be able to run the program either from the command line or from the JWM menu. I'm guessing I need to know the correct directory in which to put the program. Any help is appreciated.

How do you know that the command isn't executing from the JWM menu? All it does, you said, is output a few lines of text to the screen. So all it's doing is sending the text to STDOUT. If you don't have a terminal, STDOUT is either the terminal you started X from or your .xsession-errors file if you're using a display manager.

You probably want to add something like this to your JWM menu: 'xterm -e /usr/local/bin/your-program'

Using FreeBSD v7.0, I wrote a simple test program in c that just outputs a few lines of text to the screen. I discovered that the program apparently cannot be run from within the same directory where it resides.

This should be possible, can you post:

The source of the C program

The command you used to compile this program

The command you used to run this program

__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.

Result is a.out - cannot execute this unless i move it to /usr/local/bin. Then can run from command line, but not from JWM menu. If I try to execute it drom that directory, it prints out all files in dir. I renamed it to Junk and then can run from command line, but not from /usr/local/bin

Edit - after reading what I wrote it becomes clear that the JWM menu is executing a.out because the last line of my code is being executed - system("ls"); The files then overwrie what the program has put to screen. Also, it seems apparent that renaming the a.out file to Junk doesn't work.

I've googled and searched, but can't find an answer to my first post here.

Using FreeBSD v7.0, I wrote a simple test program in c that just outputs a few lines of text to the screen. I discovered that the program apparently cannot be run from within the same directory where it resides. So, I moved it to /usr/local/bin, and now can execute it from my home directory.

I'm using the JWM window manager, and put my c program into the JWM menu, but it won't execute from there. Both JWM and the program reside in /usr/local/bin.

I'd like to be able to run the program either from the command line or from the JWM menu. I'm guessing I need to know the correct directory in which to put the program. Any help is appreciated.

If the following command output doesnt contain the dir of your program

Don't think the problem is with ./ or path. I have no trouble running program. From the dir where it was compiled ./filename runs it. If I move the program to /usr/local/bin, I can run it from there with filename or ./filename. Only problem is that I can't get the JWM menu to execute it.

The jwmrc file is written in XML and is easy to edit. I have no trouble putting Firefox, Opera, etc in there. When i again tried inserting xterm -e /usr/local/bin/filename, as suggested, the output was just another xterm.

Truth be known, I don't even want a desktop, just something to launch programs, and JWM seemed so simple.

When i again tried inserting xterm -e /usr/local/bin/filename, as suggested, the output was just another xterm.

You may want to experiment with a sleep(3) call at the beginning of your code. I am not convinced yet that your application hasn't finished & returned to the xterm's shell prompt by the time the xterm has been fully rendered.

What does the program do? it executes a command.. prints some text.. executes another command, and then exits.

Now, if you run this program from inside "JWM", where do you think the output is going? do you think it'll just magically open a window with the output you desire?

On most POSIX systems, each program has a "terminal" tty attached to it(Unless it's a daemon.. syslog etc), and each program has 3 file descriptors, stdin, stdout and stderr.

When you run that command without any associated terminal, the output/input are effectively sent to /dev/null.

You can either delay the termination of the program with a sleep(3) call, or open an xterm and execute it manually. (Copying things over to /usr/local/bin is unnecessary, by default, the PATH environment variable sets $HOME/bin as a valid location for personal executables.).