Solved I am newbie in coding in BSD

FreeBSD 10.3, X.org+XFCE, root.
I have made this option to get IDE and compiler:
pkg install geany
pkg install gcc

after that I wrote this simple code in Geany:
Code:
#include <stdlib.h>
#include <math.h>
#include <stdio.h>

int main()
{
   int M[51];
   int j = 0;
   int i;
   for(i=0; i<52; i++)
   {
     j = (i + 1)/13;
     M = ((int)(j) + 1)*100 + (i+1);
   }
   printf("you get in 32 %d \n", M[32]);
   printf("you get in 32 %d \n", M[51]);
   getchar();
 
   return 0;
}
It was compiled and ran, but in geany_run_script_XXXXXX.sh
I opened the folder and try to run compiled file but I have get: "command not found"
chmod 777 file_name didn't helps me. What I'm doing wrong?
 
Good news everyone! I have started the file in Midnight Commander, but still get "command not found" at Terminal emulation in XFCE...
What's the problem?
 
A shot in the dark. Try prepending the script name with ./ i.e. ./geany_run_script_XXXXXX.sh. The current directory is normally not in the PATH.
 
A shot in the dark. Try prepending the script name with ./ i.e. ./geany_run_script_XXXXXX.sh. The current directory is normally not in the PATH.
Thank you, I just forget about this special of nix-systems =)))
 
What is the role of the ./ prefix to commands? Is this a shell thing or path related? I tried searching with no luck.
So there is /. and dotslash ./ used I think.
 
What is the role of the ./ prefix to commands? Is this a shell thing or path related? I tried searching with no luck.
So there is /. and dotslash ./ used I think.

It's related to $PATH. If your $PATH lacks the current directory . you have to prefix commands in your current directory with a ./, otherwise your shell will complain "command not found".
 
When you executes a command (such as ls, for example), the terminal searches the PATH variable (you can see its value expanding it with $ (like $PATH)), so ls expands to /bin/ls (I guess that's the correct path).

So, let's assume you have a executable shell script at your home folder (~/myexec.sh). Typing myexec.sh throws "command not found" because your home folder isn't in $PATH, so you need to tell your terminal where to find myexec.sh. The ./ is the same thing as $(pwd)/ ( pwd is the command which prints your current directory), so, on your home folder, ./ expands to ~/ or /home/your-name/, meaning that ./myexec.sh is the same as ~/myexec.sh or /home/your-name/myexec.sh. I might be wrong, but is something like that.
 
Back
Top