[clug] Amusing little /bin/sh question..

Andrew Janke a.janke at gmail.com
Wed May 23 07:09:30 GMT 2007


Thanks for the quick replies...

I forgot one (rather) crucial bit...  I want to find out what somevar
is but I dont want to run the script itself (thus the set -n
fiddling).



a

On 23/05/07, Peter Barker <pbarker at barker.dropbear.id.au> wrote:
> On Wed, 23 May 2007, Andrew Janke wrote:
>
> > How can I get what the value of somevar in another script, for example
>
> Would it be possible to just "source" the first script from the second?
>
> e.g.
> --------
> pbarker at apiomerus:~/test2$  cat > a.sh
> #!/bin/sh
>
> somevar="a-value"
> pbarker at apiomerus:~/test2$ cat > b.sh
> #!/bin/sh
>
> source a.sh
>
> echo "somevar=$somevar";
> pbarker at apiomerus:~/test2$ chmod +x b.sh
> pbarker at apiomerus:~/test2$ ./b.sh
> somevar=a-value
> pbarker at apiomerus:~/test2$
> -------
>
> > a
>
> > Andrew Janke   (a.janke at gmail.com || http://a.janke.googlepages.com/)
>
> Yours,
> --
> Peter Barker                          |   N    _--_|\ /---- Barham, Vic
> Programmer,Sysadmin,Geek              | W + E /     /\
> pbarker at barker.dropbear.id.au         |   S   \_,--?_*<-- Canberra
> You need a bigger hammer.             |             v    [35S, 149E]
> "Peter is apathetic, and I'm vaguely apathetic" -- Rachel, thinking of organising a movie trip
>


-- 
Andrew Janke   (a.janke at gmail.com || http://a.janke.googlepages.com/)
Canberra->Australia    +61 (402) 700 883


More information about the linux mailing list