You are not logged in.
I am running a script in v/c 2 that looks like this:
#!/bin/bash
TURNEDON=1
until [ 6 -eq 9 ]; do
if [ $TURNEDON -eq 0 ]; then
poweroff
else
sleep 5
fi
done
The idea is, it checks to see if TURNEDON has become 0 every 5 seconds and if so, turns off the computer. I would like to be able to shutdown by setting TURNEDON=0 in v/c 1.
The problem is, whenever I run TURNEDON=0, set TURNEDON=0, env TURNEDON=0 or export TURNEDON=0, this script will still see it as a 1 because I have not set TURNEDON=0 globally. Is there any command or series of steps to change the value of TURNEDON to 0 such that every process (or at least this script) will inherit it?
Last edited by ConnorBehan (2007-11-09 18:35:42)
6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.
Offline
/etc/profile
Offline
/etc/profile
No, I don't believe that would do... He wants to change the environment of a running process.
I too have been wondering if this is possible. (The only thing I found out was printing the environment of a running process 'ps auxwwe | grep processname')
Offline
I'm not sure if you can set an env variable globally, but you can use a file instead.
#!/bin/bash
until [ 6 -eq 9 ]; do
TURNEDON=`cat ~/.poweroff`
if [ "$TURNEDON" = "0" ]; then
echo 1 > ~/.poweroff
poweroff
else
sleep 5
fi
done
Then 'echo 0 > ~/.poweroff' to poweroff.
Offline
Oh I see... so instead of checking if TURNEDON=0 (in which case it check's its own environment) I'd use 'ps auxwwe | grep processname' to check if I have set TURNEDON=0 in some other process's environment. I think for my purposes it would be much easier to work with files for this. The script now looks like this.
#!/bin/bash
rm /home/dummy
until [ 6 -eq 9 ]; do
if [ -e /home/dummy ]; then
poweroff
else
sleep 5
fi
done
And to shutdown I simply run touch /home/dummy. After using this method several times I may have some claim as to why I like it better than a normal shutdown lol.
6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.
Offline
I am again in a situation where I'm trying to find how to change a process' environment. In this case it is xfce4-panel because I want to change the anchor points of the panel when I change workspaces. There is a GUI to do this quickly, but the code that happens when you click the button, isn't a shell command, it's a series of C functions and GTK API calls that I don't know how to script... so I'm trying to trick xfce4-panel into thinking I clicked the button by changing variables.
6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.
Offline
you cannot change an environmental variable "globally" in all running processes at once.
Offline
I am again in a situation where I'm trying to find how to change a process' environment. In this case it is xfce4-panel because I want to change the anchor points of the panel when I change workspaces. There is a GUI to do this quickly, but the code that happens when you click the button, isn't a shell command, it's a series of C functions and GTK API calls that I don't know how to script... so I'm trying to trick xfce4-panel into thinking I clicked the button by changing variables.
There is no clean way to do so. Best bet is to patch source code of xfce4-panel
Offline