Re: How to pass same Variable to two different scripts

From: Andrew Tkachenko (pobugfix_at_peterlink.ru)
Date: 11/29/04


Date: Mon, 29 Nov 2004 19:06:54 +0000

veny wrote on 29 Ноябрь 2004 16:03:

> Hi,
>
> I was wondering whether it is possible to pass the same variable to
> two or three scripts.
>
> Assuming that I have a script called foo.sh something like this:
> ############# foo.sh ##########
> #!/bin/sh
>
> echo "Enter Name :"
> $name
>
> ./f1.sh
> ./f2.sh
> ##############################
>
> Is it possbile to use the same varaible $name in both f1.sh and f2.sh
> scripts. For example f1.sh is just printing out the varaible:
>
> ############## f1.sh ############
> #!/bin/sh
>
> echo "Hello Mr. "
> echo $name
>
> #################################
>
> What do I need to do to print out the varaible from within f1.sh. I am
> a JAVA Developer and don't have much experience in UNIX scripting. I
> would appreciate if I can get any help from the group.
>
> Thanks in advance.
>
> Veny

export 'name' variable as environment variable.

read -p "Enter Name :" name
export name

then it'll be accessible in both f1.sh and f2.sh as $name

-- 
Andrew


Relevant Pages