开发者

i want to run a program without using terminal -- is it possible ? how?

I'm having a program that will do a file copy, but does not need terminal to print.

Now i want to run the file by double clicking ./filemove but it does not do anything. Through the terminal it works fine.

I think it's because I need to include the headers and I do not know how to include the headers to that file.

Can anybody help me? I want to know how to include header files to th开发者_开发问答e executable file or if that is not the reason than what else is the reason?

Thank you.

I use Ubuntu Linux OS. I didn't take any environmental variables and still i cant find it!


I'm going to take a stab at this and guess your problem has to do with file paths. On Linux you can absolutely run programs without the terminal. The terminal is just an interface to the application. The same is true of whatever Desktop Environment you are using.

I'm assuming that your filemove program is using relative paths. What I'm guessing is happening is that when you double click your application, the DE is running it from a different directory than the one it is in. This is pretty counter-intuitive but is possible. So if your program is in /home/user/myproject/ and you double click on it, it's possible that the DE is running it from /home/user/ instead.

I would recommend adding output to your program, and have it print out it's working directory. Since you are not running it on the CLI, have it print to a file.

EDIT: you could also try changing any relative file paths to absolute file paths and seeing if it works. That will at least tell you if the working directory is the problem or not.


If you want to further try to debug this, create a shell script that contains something like:

#!/bin/sh
exec strace /path/to/yourprogram "$@" >/tmp/strace.out 2>&1

Make the script executable, and run that instead of your program, look for clues in /tmp/strace.out Make sure you've installed the strace program (apt-get install strace)


A wild guess: Are you giving arguments to your program when you run it in the terminal? As in the command ./filemove oldname newname?

In that case, you need to give those arguments to the program in some other way. In at least some window systems- you can drag and drop files on the program icon to give it the paths of those files as arguments.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜