[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] exports do .bashrc via ssh
From: |
Paulo Bettega |
Subject: |
Re: [shell-script] exports do .bashrc via ssh |
Date: |
Tue, 27 May 2014 14:26:03 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
Olá Alfredo, também não sei porque invertendo a ordem dá certo,
mas será que não tem alguma coisa nos outros
arquivos de configuração do bash alterando as variáveis?
Segundo o manpage, o bash lê o /etc/profile, depois
~/.bash_profile, ~/.bash_login, e ~/.profile
se bem que o shell vem de uma conexão ssh, então não sei
se é considerado como shell com login e interativo ou não.
The following paragraphs describe how bash executes its startup files.
If any of the files exist but cannot be read, bash reports an error.
Tildes are expanded in filenames as described below under Tilde Expan‐
sion in the EXPANSION section.
When bash is invoked as an interactive login shell, or as a non-inter‐
active shell with the --login option, it first reads and executes com‐
mands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that
exists and is readable. The --noprofile option may be used when the
shell is started to inhibit this behavior.
Abraços Paulo Bettega
On 27-05-2014 10:31, Alfredo Casanova address@hidden [shell-script] wrote:
Robson, também olhei todo o /etc/bashrc e não vi nada desse tipo. Depois posto
ele aqui
Em 27/05/2014 08:12, "Robson Alexandre address@hidden <mailto:address@hidden>
[shell-script]" <address@hidden <mailto:address@hidden>> escreveu:
__
Provavelmente no /etc/bashrc deve haver algum exit ou erro não enviado a
STDOUT ou STDERR que
impede a continuação da execução do script.
Atenciosamente
Robson Alexandre
Em 26 de maio de 2014 21:17, Alfredo Casanova address@hidden
<mailto:address@hidden>
[shell-script] <address@hidden <mailto:address@hidden>> escreveu:
__
Ernander, soluções para o problema eu encontrei algumas... mas fiquei
curioso em saber o
motivo disso!!
2014-05-26 20:55 GMT-03:00 'Ernander (Nander)' address@hidden
<mailto:address@hidden> [shell-script] <address@hidden
<mailto:address@hidden>>:
__
Será que nesses casos a "ORDEM DOS TRATORES ALTERA O VIADUTO".
Ia te sugerir no seu shell, criar um arquivo com as variaveis e no
inicio do seu script
dar um "source arquivo_de_variaveis" ou " . arquivo de variaveis"
no caso so arquivo será que o ". /etc/bashrc" não deixa ler ou
exportar mais nada?.
Óh e agora quem poderá sanar nossa dúvida?
Em 26 de maio de 2014 17:58, Alfredo Casanova address@hidden
<mailto:address@hidden> [shell-script] <address@hidden
<mailto:address@hidden>> escreveu:
__
Fala galera
Fiz um script numa maquina, pra ser executado via ssh, e setei
algumas variaveis de
ambiente que são necessárias no .bashrc.
Acontece que tive alguns problemas
o .bashrc estava assim:
/
/
/# Source global definitions/
/if [ -f /etc/bashrc ]; then/
/. /etc/bashrc/
/fi/
/
/
/export VAR1=value1/
/export VAR2=value2/
/export VAR3=value3/
e quando dava
$ ssh login@host comando
ele agia como se nao carregasse as variaveis de ambiente.
testei assim:
/$ ssh login@host "ps -p $$"/
/ PID TTY TIME CMD/
quebrei a cabeça e achei algumas solucoes, tipo:
$ ssh login@host "bash -l -c 'comando'"
e
$ ssh login@host 'bash -l -c "ps -p $$"'
stdin: is not a tty
PID TTY TIME CMD
25999 ? 00:00:00 ps
e aí funcionou... mas ainda não tinha entendido pq as variaveis
setadas no .bashrc
nao estavam sendo lidas em non-interactive shell
Aí não sei pq cargas d'agua resolvi mudar o .bashrc acima,
mudei a posicao dos exports
export VAR1=value1
export VAR2=value2
export VAR3=value3
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
e aí o script passou a funcionar por SSH! PORQUE???????
--
[]'s
Alfredo Casanova
Linux User #228230
msn: address@hidden <mailto:address@hidden>
tel: +55 61 9655 9619 <tel:%2B55%2061%209655%209619>
--
[]'s
Alfredo Casanova
Linux User #228230
msn: address@hidden <mailto:address@hidden>
tel: +55 61 9655 9619 <tel:%2B55%2061%209655%209619>