[bash] How to execute binary?

Questions about applications and software
Forum rules
Before you post please read this

[bash] How to execute binary?

Postby Bren on Wed Jul 23, 2008 9:07 am

Suppose I've just made an executable file, how do I run it in the terminal? It never runs, but if I run it from Gnome Commander it does open a terminal.
Bren
Level 1
Level 1
 
Posts: 20
Joined: Sun Jul 13, 2008 6:23 pm

Linux Mint is funded by ads and donations.
 

Re: [bash] How to execute binary?

Postby Husse on Wed Jul 23, 2008 9:19 am

First off- have you made it executable chmod +x your_file
then, in the same folder or with the full path, it's just your_file > Enter
Perhaps gnome commander makes the assumption it should open a terminal
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19714
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: [bash] How to execute binary?

Postby Bren on Wed Jul 23, 2008 11:02 am

Strange. That's what I tried the first few times and it doesn't work. The file is executable (it shows rwx------ so I assume it is) and it looks green in bash. It gives me the message bash: filename: command not found. (I thought it was chmod + to add instead of -.) I am also in the relevant directory.
Bren
Level 1
Level 1
 
Posts: 20
Joined: Sun Jul 13, 2008 6:23 pm

Re: [bash] How to execute binary?

Postby Husse on Thu Jul 24, 2008 5:48 am

I have corrected my typo - indeed is + to add and - to remove executable
Do you use autocomplete?
That is the wonderful capacity of bash to fill out the name if you give a few letters in the beginning
If not you may spell it wrong - and U is not the same as u - case matters
If you can't autocomplete you are not in the same directory - I've done the mistake many times especially with the desktop
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19714
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: [bash] How to execute binary?

Postby Bren on Thu Jul 24, 2008 8:04 am

I am in ~/Source/D where the executable file, fifth, is. "ls -lh" shows that it's there, and the prompt shows I am in ~/Source/D as "pwd" shows it too. I type in "fifth" (without quotation marks) and bash gives me the same error (command not found). I tried "bash fifth" and it "cannot execute binary file". What is the reason it cannot execute?

I don't know what you mean by autocomplete, though. I don't use it and don't see the relevance. If I remember correctly, it was done with TAB, right? I tried it -- had to press two times -- and it displayed a question "Show all n possibilities?" I said yes and it shows me unrelated files that aren't even in the directory. This contradicts with your "not being in the same directory, as "pwd" and the prompt (~/Source/D) prove that I'm in the relevant directory.
Bren
Level 1
Level 1
 
Posts: 20
Joined: Sun Jul 13, 2008 6:23 pm

Re: [bash] How to execute binary?

Postby Husse on Sat Jul 26, 2008 6:33 am

To start with autocomplete
Lets say you want to run the md5sum command for a Mint ISO - instead of typing all that you type Li and then tab and you you get it if there are no other files beginning with Li - then you get what's common and add the next character + tab :) (I know you can right click in Elyssa)
From your answers I conclude it is not a PATH problem rather a problem with the file
You could get the "cannot execute binary file" error because the system
doesn't know what to do with the file -- it may not be a compiled
binary, and there's no "shebang" (#!bash) line telling it what interpreter
to use if it's a script
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19714
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: [bash] How to execute binary?

Postby Bren on Fri Aug 01, 2008 1:40 pm

I still don't see what autocomplete has to do with it nor whether the file is in error, but thanks anyway.

I found the simple answer by accident: I had to put ./ in front of the file name which wasn't necessary in Windows. Now that I know this little stupid detail, I am finally comfortable to an acceptable level in the terminal :)
Bren
Level 1
Level 1
 
Posts: 20
Joined: Sun Jul 13, 2008 6:23 pm

Re: [bash] How to execute binary?

Postby Husse on Sat Aug 02, 2008 4:44 pm

I had to put ./ in front of the file name

This tells bash to execute "here" - sorry I forgot to mention it as it is not always necessary It should have been mentioned in the readme if one exists
Oh
the autocomplete is wonderful to avoid misspelling
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19714
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Linux Mint is funded by ads and donations.
 

Return to Software & Applications

Who is online

Users browsing this forum: mintybreath and 27 guests