The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
global variable not being set robotball Shell Programming and Scripting 5 06-10-2008 06:20 AM
global variable in awk anhtt Shell Programming and Scripting 1 03-16-2008 03:55 PM
setting a global variable in script arunkumar_mca UNIX for Dummies Questions & Answers 3 10-23-2007 07:46 AM
Global Variable in awk... ZINGARO Shell Programming and Scripting 1 07-04-2007 01:07 PM
Global variable becomes local odashe318 Shell Programming and Scripting 2 10-29-2004 09:18 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-11-2007
skyineyes skyineyes is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 150
Global Variable in a script?

How to create a Global variable within a script file.

say i want a varaible called LOGFILE to be used within all the script.

how to do that?
  #2 (permalink)  
Old 07-11-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Skyineyes,
If you want to reference a variable in the same shell script,
there is nothing special you need to do, just assign the value
and use it.

If you want to use the variable across shell scripts:
Code:
export myvar="Test"
  #3 (permalink)  
Old 07-12-2007
psiva_arul's Avatar
psiva_arul psiva_arul is offline
Registered User
  
 

Join Date: Jul 2007
Location: Bangalore, India
Posts: 97
if we want to access the variable across the shell also the entire UNIX server, you can create a variable in ENV file. but you should use the "export" keyword prefix of the variable.

eg:

export VAR_NAME;

Then you can access the variable name VAR_NAME in across the shell and acros the unix server for you username login.


Thanks,
Siva.P
Bangalore
Sponsored Links
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 08:28 PM.


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