Simple Bash Script Question

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Bob Cober
Date:  
Subject: Simple Bash Script Question
Thanks Lynn that was it....

On Mon, 2002-01-28 at 08:07, Lynn David Newton wrote:
> On the off chance you haven't already gotten fifty replies on this:
>
> > I am having trouble exporting a shell variable from a Bash script.
> >
> > Here is the script test.sh:
> > #! /bin/sh
> > echo it works
> > export IA32ROOT="/opt/intel/compiler50/ia32"
> > echo done
> >
> > Here is the output:
> > [root@localhost bin]# ./test.sh
> > it works
> > done
> > [root@localhost bin]# echo $IA32ROOT
> >
> > [root@localhost bin]#
> >
> > As you can see, there is no export nor any error...
>
> When you run it in a script like that, you fork a subshell to run the
> script. It runs just fine. Insert an echo $IA32ROOT statement in your script
> and you will see it. But when the script ends, so does the subshell.
>
> It's apparently your desire to set the value of that variable in your
> running shell. To do that, "source" the script by running it with the "."
> (dot) command:
>
> . ./test.sh
>
> should do it for you.
>
> --
> Lynn David Newton
> Phoenix, Arizona
>
> ________________________________________________
> See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't post to the list quickly and you use Netscape to write mail.
>
> PLUG-discuss mailing list -
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss