executable question

Using Leap 15.1 with KDE.

I’m using gfortran from a konsole and notice the following.

gfortran can be executed from a command line

as follows

 gfortran  

but not by

 ./gfortran.exe 

Why Is this?

Thank you

Hi
Because gfortran is a ‘linux’ executable and in set in your application path;


which gfortran
echo $PATH

A file with an exe extension is normally a windows executable and won’t work (well via win perhaps), but the ./ is important as this is saying there is a file in the directory I am (pwd) and I want to execute it, but it must have permissions set to be executable as well (0755 or 0700). There are other methods,

For example, I created a test script (two lines), extensions do generally mean something eg .pl for perl, .py for python etc


cat test.sh

#!/usr/bin/bash
echo "Hello World"

sh test.sh

Hello World

./test.sh

bash: ./test.sh: Permission denied

ls -la test.sh

-rw-r--r-- 1 blah users 36 Jan 18 07:38 test.sh

chmod 0700 test.sh

ls -la test.sh

-rwx------ 1 blah users 36 Jan 18 07:38 test.sh

./test.sh

Hello World

Hi,

Because gfortran in in your PATH, the value/output of echo “$PATH”. You can can use the builtin type utility.

type -a gfortran

So the next thing is ./ which means the current pwd or the value of $PWD or directory or folder for windows users. So if there is no executable within your current pwd, $PWD, directory, folder then ./ will surely give you an error.

The bash man page may shed some light, i hope.

PAGER='less +/^command\ execution' man bash