[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OFF-TOPIC - shell script, exportando variaveis



Justamente por estarem ligadas a sessões você precisa
do comando source para que variáveis shell sejam
exportadas entre scripts.  Elas ficam disponíveis no
shell ou terminal corrente para qualquer script que
precise usá-las.  Fui um dos que falou sobre o source.
 Se você estiver correto, então o Debian não segue a
própria documentação.  Faça o seguinte teste:
  #!/bin/bash
  #teste1.sh
  export ECHO="teste"

  #!/bin/bash
  #teste2.sh
  echo $ECHO

Em um terminal:

  $chmod u+x teste1.sh
  $chmod u+x teste2.sh
  $source teste1.sh; ./teste2.sh

A saída que obtive foi, surpreendentemente:
  teste

O comando source pode fazer isto porque ele é interno
ao bash.  Digite man bash em um terminal e procure por
SHELL BUILTIN COMMANDS.  Você encontrará:
     source filename [arguments]
        Read and execute commands from filename  in 
the  "current  shell environment" (as aspas são
minhas)  and return the exit status of the last
command executed from filename.  If filename does not
contain a slash, file              names  in  PATH 
are used to find the directory containing file name. 
The file searched for in PATH  need  not  be 
executable. When  bash  is  not  in  posix  mode,  the
 current directory is searched if no file is found in
PATH.  If the sourcepath  option              to  the 
shopt  builtin  command  is turned off, the PATH is
not searched.  If any arguments are supplied, they
become the  positional  parameters  when  filename  is
 executed.  Otherwise the positional parameters are
unchanged.  The return status  is  the status  of  the
 last  command exited within the script (0 if no      
       commands are executed), and false if filename
is  not  found  or cannot be read.

Quando sugeri o source não foi chute, foi experiência
e estudo.
Mas, se você estiver certo, quem estuda grid computing
ao redor do mundo usando o Globus Toolkit
(www.globus.org) não sabe o que está fazendo e o que
está sendo feito na verdade não deveria acontecer.  Da
documentação do Globus
(http://www-unix.globus.org/toolkit/docs/3.2/installation/install_config_req.html#setenv):
Setting environment variables
In order for the system to know the location of the
Globus Toolkit commands you just installed, you must
set an environment variable and source the
globus-user-env.sh script.
1 	

As globus, set GLOBUS_LOCATION to where you installed
the Globus Toolkit.

This will either be export
GLOBUS_LOCATION=/path/to/install or setenv
GLOBUS_LOCATION /path/to/install.
2 	

Source $GLOBUS_LOCATION/etc/globus-user-env.{sh,csh}
depending on shell.

    * .sh for Bourne shell
    * .csh for C shell

Mas, se ainda assim você achar que está certo,
inscreva-se na lista discuss@globus.org e conte ao
mundo que o mundo está errado e que o que o mundo está
fazendo não deveria funcionar e que o mundo não lê a
documentação.  Mais informações sobre como entrar na
lista em
http://www-unix.globus.org/toolkit/support.html

Faça um favor a você mesmo: antes de dizer que algo
não funciona, teste.  Ao dizer que algo está em alguma
documentação, cite a fonte para que outros possam
pesquisar.

Peço desculpas aos outros integrantes da lista pelo
tamanho e tom do email.

 --- Igor Morgado <igormorgado@gmail.com> escreveu: 
> O que adianta toda a explicacao se voces nao estao
> entendendo o que
> esta acontecendo?
> 
> As variaveis no shell estao intimamente ligadas a
> sessoes.
> 
> Voce exporta variaveis para sessoes filhas mas nunca
> para sessoes pai,
> ou irmas (derivadas do mesmo pai).
> 
> Quando voce utiliza o comando source ou . voce esta
> executando um
> script no shell atual *(como se estivesse digitanto)
> enquanto a
> execucao de um script abre um sub-shell ( ps axfww
> mostra isso muito
> bem).
> 
> Gente LEIAM AS DOCUMENTACOES ANTES DE PERGUNTAR OU
> FICAR CHUTANDO.



	
	
		
_______________________________________________________ 
Yahoo! Mail - Agora com 250MB de espaço gratuito. Abra 
uma conta agora! http://br.info.mail.yahoo.com/



Reply to: