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
e quando dava
$ ssh login@host comando
ele agia como se nao carregasse as variaveis de ambiente.
testei assim:
$ ssh login@host "ps -p $$"
quebrei a cabeça e achei algumas solucoes, tipo:
$ ssh login@host "bash -l -c 'comando'"
$ 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
tel: +55 61 9655 9619