LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Can't execute using ./ in bash anymore (http://www.linuxquestions.org/questions/linux-software-2/cant-execute-using-in-bash-anymore-759513/)

quietIdentity 10-03-2009 10:21 PM

Can't execute using ./ in bash anymore
 
Hi I'm using Ubuntu 9.04 and I've encountered a very odd error. I sat down this evening do to an assignment and went to run a C++ executable compiled using g++ in the normal way ./programName and all I get is 'No such file/directory 'programName'. I've tried this with all manner of executable from various programs I've made over the years and it won't work for anything. I'm sure it's something rather minor that's causing the error, I can't figure it out though. Since I'm meant to be finishing this assignment tonight it's rather frustrating, I'm using emacs over an SSH connection to finish it off on a computer that works now properly now, but working on it locally, and fixing this problem would be really really great.

Thanks, I guess this is some sort of punishment for trying to finish work the day before it's due :-(

lutusp 10-03-2009 10:37 PM

Quote:

Originally Posted by quietIdentity (Post 3706713)
Hi I'm using Ubuntu 9.04 and I've encountered a very odd error. I sat down this evening do to an assignment and went to run a C++ executable compiled using g++ in the normal way ./programName and all I get is 'No such file/directory 'programName'. I've tried this with all manner of executable from various programs I've made over the years and it won't work for anything. I'm sure it's something rather minor that's causing the error, I can't figure it out though. Since I'm meant to be finishing this assignment tonight it's rather frustrating, I'm using emacs over an SSH connection to finish it off on a computer that works now properly now, but working on it locally, and fixing this problem would be really really great.

Thanks, I guess this is some sort of punishment for trying to finish work the day before it's due :-(

1. Check that you are really in the directory you think you are:

Code:

$ pwd
2. Check that the file you think is present, is actually present:

Code:

$ ls
3. Make sure the file is executable:

Code:

$ ls -la (look for permission bits including 'x' for the user you are)
If you are in the right directory, and if the file is in that same directory, and if it is executable, then make sure you are giving it the right spelling.

kirukan 10-03-2009 11:28 PM

To compile
g++ myprogram.cc
This will create the a.out file and to execute this file
./a.out

OR

g++ -o myprogram myprogram.cc
./myprogram


All times are GMT -5. The time now is 02:15 PM.