Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-11-2010, 11:31 AM   #1
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Rep: Reputation: 39
Smile Source or Execute an external Script from shell script

Hi All,

I know this is a simple to answer one... but its hard to search google for source'ing or executing a script with '. script'.

Basically, i've realised it seems possible to have one script...
echo $@
The thing is...
./ 123 456

123 456
I didn't realise the args of script would be passed to and able to be used in script

Just wondering why this happens more than anything? Its not a problem or anything really... just interested.

Thanks and Regards,
Old 08-11-2010, 12:01 PM   #2
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
When you source a script, rather than call it explicitly, it inherits the environment of the script which sourced it. Therefore, the parameters passed to the original script initially, are available to the sourced code. When you source a second script into a first one, it acts as though the sourced code is part of the original script, i.e. it acts as though it were all one script.
Old 08-11-2010, 12:48 PM   #3
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
Ahh course, should have known that really :-)

Thanks and great explaination!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to execute Source command in a shell script UltraSoul Linux - General 3 09-23-2010 10:13 AM
How can i execute shell script from firefox? solo9300 Linux - General 3 09-30-2009 10:13 AM
help with execute mulitple shell script within shell script ufmale Programming 6 09-13-2008 12:21 AM
shell script won't execute brandnewbie Linux - Newbie 7 08-10-2004 01:30 PM
shell script how to execute x2000koh Programming 6 07-29-2003 04:20 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:30 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration