Main Page | Report this Page
Linux Forum Index  »  General Linux Discussion  »  making an executable script file...
Page 1 of 1    

making an executable script file...

Author Message
Marcel...
Posted: Tue Aug 25, 2009 9:52 pm
Guest
Hello,
a small question I'd like to ask.
I have written a small text file with the purpose of making a script file. I
called it 'm' and it contains two lines, cd marcel, cd files
How can I make this script file executable?
When I now do m + enter, I get the error message Missing filename.
Thanks in advance and best regards,
Marcel
 
J.O. Aho...
Posted: Tue Aug 25, 2009 10:29 pm
Guest
Marcel wrote:
Quote:
Hello,
a small question I'd like to ask.
I have written a small text file with the purpose of making a script
file. I called it 'm' and it contains two lines, cd marcel, cd files
How can I make this script file executable?
When I now do m + enter, I get the error message Missing filename.

There is two things you need to do

1. Tell what tool to use to execute the script with, if you made a bash script
then add the following line as the first one:
#!/bin/bash

secondly you need to set it be executeble
chmod 755 m

if the script (the directory where the script is) isn't in your $PATH, then
you need to do ./m (if you are in the same directory) or give the full path to
the script.

--

//Aho
 
Marcel...
Posted: Tue Aug 25, 2009 10:42 pm
Guest
"J.O. Aho" <user at (no spam) example.net> schrieb im Newsbeitrag
news:7fjs3hF2lnm7uU1 at (no spam) mid.individual.net...

Quote:
1. Tell what tool to use to execute the script with, if you made a bash
script then add the following line as the first one:
#!/bin/bash

Hi //Aho

I have written the script file in the root directory of my Dreambox.
In the bin directory there is not 'bash' rather 'ash'. Is that a script for
the same purpose?

Best, Marcel
 
jellybean stonerfish...
Posted: Tue Aug 25, 2009 10:53 pm
Guest
On Wed, 26 Aug 2009 05:52:55 +0200, Marcel wrote:

Quote:
Hello,
a small question I'd like to ask.
I have written a small text file with the purpose of making a script
file. I called it 'm' and it contains two lines, cd marcel, cd files How
can I make this script file executable? When I now do m + enter, I get
the error message Missing filename. Thanks in advance and best regards,
Marcel

Even if you follow j.o.aho's advice, your script will do nothing.

Well it will do something, it will cd into the marcel/files directory.
Then when the script ends, you will be back where you started. The cd
commands in your script will only affect the subshell that exists as your
script is running. If you want to use this script to cd your current
shell into the marcel/files directory you can source the file. Then the
executable flag and the shebang "#/bin/bash" are not needed.
 
philo...
Posted: Wed Aug 26, 2009 1:31 am
Guest
Marcel wrote:
Quote:
Hello,
a small question I'd like to ask.
I have written a small text file with the purpose of making a script
file. I called it 'm' and it contains two lines, cd marcel, cd files
How can I make this script file executable?
When I now do m + enter, I get the error message Missing filename.
Thanks in advance and best regards,
Marcel


You need to use the chmod command

or do it from the GUI
 
ray...
Posted: Wed Aug 26, 2009 8:01 am
Guest
On Wed, 26 Aug 2009 05:52:55 +0200, Marcel wrote:

Quote:
Hello,
a small question I'd like to ask.
I have written a small text file with the purpose of making a script
file. I called it 'm' and it contains two lines, cd marcel, cd files How
can I make this script file executable? When I now do m + enter, I get
the error message Missing filename. Thanks in advance and best regards,
Marcel

I see only three problems:

1) the current directory may not be in your 'path', so do "./m" then
enter.

2) make it executable "chmod +x m"

3) assuming you want the actions to be permanent: "source ./m" - "source
m" may work, I'm not sure.
 
J.O. Aho...
Posted: Wed Aug 26, 2009 10:23 am
Guest
Marcel wrote:
Quote:
"J.O. Aho" <user at (no spam) example.net> schrieb im Newsbeitrag
news:7fjs3hF2lnm7uU1 at (no spam) mid.individual.net...

1. Tell what tool to use to execute the script with, if you made a
bash script then add the following line as the first one:
#!/bin/bash

I have written the script file in the root directory of my Dreambox.
In the bin directory there is not 'bash' rather 'ash'. Is that a script
for the same purpose?

Yes, ash is a different shell than bash, just keep in mind that the script may
not work if you move it to another machine.

The root directory isn't in $PATH, so every time you use it, you need to give
it the full path (or relative from where your current directory). I do suggest
you put it in /usr/local/bin (if you have a such directory), as you won't then
need to give the full path and it will not messing up with files for the
distribution you are using.


--

//Aho
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Tue Nov 24, 2009 8:14 am