The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Accessing variables of one shell script in another shell script rsendhilmani Shell Programming and Scripting 2 03-17-2009 01:17 AM
invoking a shell script inside cgi shell script smriti_shridhar Shell Programming and Scripting 2 07-09-2008 02:50 AM
How to pass a parameter from one Shell-script to another Shell-script subodhbansal Shell Programming and Scripting 2 09-22-2007 06:19 AM
How to Run a shell script from Perl script in Parent shell? hifake Shell Programming and Scripting 16 08-28-2007 09:42 PM
Have a shell script call another shell script and exit heprox Shell Programming and Scripting 2 11-20-2006 08:17 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-17-2008
vijay_0209 vijay_0209 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 52
Shell script

I have two scripts a.shl and b.shl. In the script b.shl, there is a line

". a.shl"

what does this denote?
  #2 (permalink)  
Old 09-17-2008
subhendu81 subhendu81 is offline
Registered User
  
 

Join Date: Sep 2008
Location: mumbai
Posts: 78
hi vijay,

its calling the script a.shl inside b.shl. i mean to say script a.shl is running in b.shl.

dot(.) is there before a.shl .it denotes the working directory.
  #3 (permalink)  
Old 09-17-2008
vijay_0209 vijay_0209 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 52
subhendu81,I am afraid that might be wrong....Im not sure what it does but I am sure the script a.shl is not being run here....bcos I tested it by givin some echo statements in a.shl.....So a.shl is not being run here...Also note there is a space between "." and "a.shl"..so dot does not denote current dir

Last edited by vijay_0209; 09-17-2008 at 02:25 AM..
  #4 (permalink)  
Old 09-17-2008
subhendu81 subhendu81 is offline
Registered User
  
 

Join Date: Sep 2008
Location: mumbai
Posts: 78
hi,

can u plz send me the code..so that i can clarify ur doubt easily...
  #5 (permalink)  
Old 09-17-2008
vijay_0209 vijay_0209 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 52
contents of a.shl


echo "hi"
echo "this a.shl"
. b.shl
echo "$a"
echo "done"


contents of b.shl

export a="var"
echo "this is b.shl"
  #6 (permalink)  
Old 09-17-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
The dot is the shell's "source" command. When you run one script from another, normally they are distinct processes, and the child process cannot change anything in the parent process. In some scenarios you want the invoked script to modify the invoker's environment (typically, to set some environment variables) and in those scenarios, the "source" command is the ticket.

In this particular case, the value of $a is visible inside a.shl after it sources b.shl. Without the dot, this would not be the case.

(Conventionally .sh is used as the extension for shell scripts; but often, it's better to not have any extension.)
  #7 (permalink)  
Old 09-17-2008
vijay_0209 vijay_0209 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 52
Thanks era...i think that answers my question....thanks very much
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0