Logo 
Search:

Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds

Source a script

  Date: Dec 07    Category: Unix / Linux / Ubuntu    Views: 325
  

Please tell me how to source a script.
My script is here: /home/klaus/scisoft/bin/Setup.bash

Share: 

 

9 Answers Found

 
Answer #1    Answered On: Dec 07    

cmd prompt:
cd home/klaus/scisoft/bin/
.Setup

 
Answer #2    Answered On: Dec 07    

Could you help educate us beginners here a bit please?

What does "Source a script" mean?

What does .Setup do?

 
Answer #3    Answered On: Dec 07    

There are two ways to run a script in the bash shell (what you are
most likely to use), as well as other shells I've used.

The obvious way:

abc@flenser$ ./foo

starts another bash shell running as a child of your current bash
shell. This shell runs the commands and exits.

The other way, sourcing a script is done like this:

abc@flenser$ . foo

(notice the space between the "." and "foo") This method causes your
current shell to execute the commands in the script rather than
starting a new shell to do it. The reason you might want to do this is
that any changes you make to the environment when you source a shell
affect the shell that you are running interactively, the other way
does not allow this.

 
Answer #4    Answered On: Dec 07    

Sourcing a script is different from running a script.

To source the script, you'd invoke the source directive, by the keyword
source:

source /home/klaus/scisoft/bin/Setup.bash

Or with the abbreviation for the source keyword:

. /home/klaus/scisoft/bin/Setup.bash

 
Answer #5    Answered On: Dec 07    

Thanks, but I still don't understand. I have tried to read it up but
don't understand what I am reading!

How is source myscript

different from simply

myscript

(assuming all paths and permissions are right)?

 
Answer #6    Answered On: Dec 07    

The difference is this:

Running a script starts a new shell, with a new environment. When the
script is done. that shell exits and any variables that were set in that
shell are gone.

Sourcing a script runs the script in the current shell, thus it shares
the variables with your current shell session, When the script exits,
any variables it set are still set since they were set in your current
environment.

 
Answer #7    Answered On: Dec 07    

Now I understand why I wasn't getting the
results I expected from a script I wrote to modify my Include_Path environment
variable.

 
Answer #8    Answered On: Dec 07    

Look please what I tried to get the script running:

klaus@klaus-desktop:~$ source /home/klaus/scisoft/bin/Setup.bash
klaus@klaus-desktop:~$ . /home/klaus/scisoft/bin/Setup.bash
klaus@klaus-desktop:~$ '/home/klaus/scisoft/bin/Setup.bash'
/home/klaus/scisoft/bin/Setup.bash: line 347: return: can only `return' from a
function or sourced script
/home/klaus/scisoft/bin/Setup.bash: line 350: /usr/sbin/sestatus: No such file
or directory
As you look at the output for line 347 you understand why I asked for sourcing a
script!?
I am afraid your advise doesn´t work or is there a missunderstanding??

 
Answer #9    Answered On: Dec 07    

At one time I owned a 30 1/2 ft Crocker ketch. She had a neutral helm on
both tacks. I liked it and left he that way.She would sail herself on
either tack. She also would sail herself on a beam reach with her mizzen
tightened in a little more than the main and mizzen. There was a bulge
in her port side behind th shipmate wood stove. I removed the stove and
sealing and found her frames rotten. I got the offsets and made new
steam bent frames and did a little replanking . She was fair and pretty.
She would no longer sail herself on,I think it was the starboard tack.
The next years when she was on the railway a friend noticed that her
mizzen was out of line with the main about 6 inches at the top. I
straightened It up and she would again sail herself on both tacks. I
guess the previous owner had canted the mast off to compensate for the
bulge in her hull.
I have been able to get the helm neutral on most of the boats I have
owned because I single hand and it's nice to be able to head her up to
wind go below and make a pot of coffee. More than one person has told
me over the years, your going to fall overboard one day and she will run
off and leave you . With a short life line I would expect to stay with
her.
Anyway the point is it don't take much to foul up the balance on a
sailboat.

 
Didn't find what you were looking for? Find more on Source a script Or get search suggestion and latest updates.




Tagged: