Local variable shell/new shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Local variable shell/new shell
# 1  
Old 12-04-2009
Local variable shell/new shell

Hi!
I'm trying to figure out how to reuse an "old" variable in a new bourne shell.
Am i supposed to use the export function?
If i write:

Code:
NAME="Simon"
echo $NAME

it returns Simon, but if i start a new shell and write

Code:
echo $NAME

it can't be found of course. How do i solve this?

Thanks folks!
# 2  
Old 12-04-2009
Yes, try export, but counts only for sub shells that have been started from your original shell.
# 3  
Old 12-04-2009
Allright, i'll try that, Thanks!
# 4  
Old 12-04-2009
or try adding that in .profile file..
Code:
NAME="Simon"
export $NAME

# 5  
Old 12-04-2009
can u all focus more on the use of command EXPORT . In my pjct too i have seen, some scripts are written but many times they are storing the value as Export var = "....."
why is the export command used?
# 6  
Old 12-04-2009
Quote:
can u all focus
That can be written a bit more polite next time Smilie

They use export like the original poster to make variables in subsequent started shells, programs etc. available. Some programs need/expect information given by variables like paths etc. That is why.
# 7  
Old 12-04-2009
Hi Isha,

Quote:
Originally Posted by isha_1
can u all focus more on the use of command EXPORT . In my pjct too i have seen, some scripts are written but many times they are storing the value as Export var = "....."
why is the export command used?

If u check help page of export u will get info.
use following command

man export


set, unset, setenv, unsetenv, export - shell built-in functions to determine the characteristics for environmental variables of the current shell and its descendents.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To run a local shell script in a remote machine by passing arguments to the local shell script

I need to run a local shell script on a remote machine. I am able to achieve that by executing the command > ssh -qtt user@host < test.sh However, when I try to pass arguments to test.sh it fails. Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies

2. UNIX for Dummies Questions & Answers

SQL block in a Shell Script connecting to a local and remote DB

Hi All, In a Shell scriipt with a SQL block I want to issue a query against a local DB and a remote DB on a remote server. The shell script is running locally. This is how I connect to the local server. But I want the query to reference remote table in the join. Question can I specify a... (1 Reply)
Discussion started by: daveu7
1 Replies

3. Shell Programming and Scripting

how to assign more than 1 variable value from 1 common shell to many other shell files

i have 1 file say LogDirectory='/var/tmp/logs' DataDirectory='/var/tmp/data' DBUSER='scott' now i want to access these variables in many files where #!/bin/bash ${DBUSER} , ${DataDirectory} are called how do i do that? Video tutorial on how to use code tags in The UNIX and Linux... (2 Replies)
Discussion started by: Gl@)!aTor
2 Replies

4. Shell Programming and Scripting

C Shell path variable causing very slow shell!?HELP

I am using C Shell MKS Toolkit and I ran into a huge problem when setting up some environment variables.:confused: The csh script that I have as my login script runs fine but very very slow. When I add a directory to my PATH it seems to slow down shell startup and even slow down the commands. ... (0 Replies)
Discussion started by: vas28r13
0 Replies

5. Shell Programming and Scripting

Shell scripting problems - Commands not on local machine

Hello all- I have done a lot of searching tonight, but all leads seem to be dead ends. Forgive me if this has been covered, but I've searched the forum and the internet. I am having trouble building a shell script which uses SSH to login to our schools 1024 cluster grid. The issue that I am... (1 Reply)
Discussion started by: Sagan
1 Replies

6. Shell Programming and Scripting

Executing shell script on local machine

Hi guys, I need to run and test some shell script. At work, i work on ksh. I don't have any such software/client installed at home and i cannot always connect to work from home. At home i have Windows Vista. Is there a free and reliable software where i can run my ksh script? Please let me... (4 Replies)
Discussion started by: jakSun8
4 Replies

7. Linux

Local shell script need to be executed on a remote linux box

I need to execute a shell script on a remote linux box. But the shell script resides on the local linux box where I am currently logged in. Is there a way to do this? I know rsh <host> <command> can execute a command on the remote host. (6 Replies)
Discussion started by: rajeshomallur
6 Replies

8. Shell Programming and Scripting

Shell script to create local homes

Hi I am trying to write a login script for network based clients (OSX) that looks up local accounts eg admin, root, etc and exits the script so that it doesn't apply to them. Then for everyone else I make folders eg movies, music, etc that are placed in local harddrive rather than the default... (11 Replies)
Discussion started by: Steve Adcock
11 Replies

9. Shell Programming and Scripting

Knowing the shell, no using $SHELL variable

How I can Know the shell type for a session?? I don't want use the $SHELL variable because this return (for example) "/bin/ksh" and I need some just like "ksh" in my script... I need just the shell type and not the path.... Exist any command for this??... Thanks!! (3 Replies)
Discussion started by: gloprest
3 Replies

10. UNIX for Dummies Questions & Answers

shell script, reading and resetting local variables

Hello, I have a problem with trying to run a shell script that reads in user input, validates, and sets to a 'default' value if the input is not valid. I cannot get the portion of resetting to a default value to work. These lines are skipped, and the value of x is still whatever the user... (1 Reply)
Discussion started by: b888c
1 Replies
Login or Register to Ask a Question