Skip to main content

I'm trying to define environment variable for non-interactive console in Raspbian.

In theory iI need to add the varaibles to ~/.bashrc or ~/.profile or /etc/bash.bashrc or /etc/profile. For example iI add this line  (according to the file where I added it):

export VTEMP="set on ~/.bashrc"
export VTEMP="set on ~/.profile"
export VTEMP="set on /etc/bash.bashrc"
export VTEMP="set on /etc/profile"

If iI write this lines in all files and logged via ssh, then putting the command: echo $VTEMP return: set on ~/.profile

If iI go to the raspberry pi, open an LXTerminal and put these command echo $VTEMP return: set on ~/.bashrc

But if iI try non-interactive remotely using ssh, writing: ssh [email protected] "echo $VTEMP > out.txt", when I go to see the content of the file out.txt there's nothing, it empty.

Why VTEMP isn't VTEMP defined when useusing non-interactive?

I'm trying to define environment variable for non-interactive console in Raspbian.

In theory i need to add the varaibles to ~/.bashrc or ~/.profile or /etc/bash.bashrc or /etc/profile. For example i add this line(according to the file where I added it):

export VTEMP="set on ~/.bashrc"
export VTEMP="set on ~/.profile"
export VTEMP="set on /etc/bash.bashrc"
export VTEMP="set on /etc/profile"

If i write this lines in all files and logged via ssh, then putting the command: echo $VTEMP return: set on ~/.profile

If i go to the raspberry pi, open an LXTerminal and put these command echo $VTEMP return: set on ~/.bashrc

But if i try non-interactive remotely using ssh, writing: ssh [email protected] "echo $VTEMP > out.txt", when I go to see the content of the file out.txt there's nothing, it empty.

Why VTEMP isn't defined when use non-interactive?

I'm trying to define environment variable for non-interactive console in Raspbian.

In theory I need to add the varaibles to ~/.bashrc or ~/.profile or /etc/bash.bashrc or /etc/profile. For example I add this line  (according to the file where I added it):

export VTEMP="set on ~/.bashrc"
export VTEMP="set on ~/.profile"
export VTEMP="set on /etc/bash.bashrc"
export VTEMP="set on /etc/profile"

If I write this lines in all files and logged via ssh, then putting the command: echo $VTEMP return: set on ~/.profile

If I go to the raspberry pi, open an LXTerminal and put these command echo $VTEMP return: set on ~/.bashrc

But if I try non-interactive remotely using ssh, writing: ssh [email protected] "echo $VTEMP > out.txt", when I go to see the content of the file out.txt there's nothing, it empty.

Why isn't VTEMP defined when using non-interactive?

Source Link
Sgz
  • 23
  • 1
  • 1
  • 3

Bash environment variables in non interactive mode

I'm trying to define environment variable for non-interactive console in Raspbian.

In theory i need to add the varaibles to ~/.bashrc or ~/.profile or /etc/bash.bashrc or /etc/profile. For example i add this line(according to the file where I added it):

export VTEMP="set on ~/.bashrc"
export VTEMP="set on ~/.profile"
export VTEMP="set on /etc/bash.bashrc"
export VTEMP="set on /etc/profile"

If i write this lines in all files and logged via ssh, then putting the command: echo $VTEMP return: set on ~/.profile

If i go to the raspberry pi, open an LXTerminal and put these command echo $VTEMP return: set on ~/.bashrc

But if i try non-interactive remotely using ssh, writing: ssh [email protected] "echo $VTEMP > out.txt", when I go to see the content of the file out.txt there's nothing, it empty.

Why VTEMP isn't defined when use non-interactive?