"env" variable problem? [ Solved ]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

"env" variable problem? [ Solved ]

#1 Post by sunburnt »

I`ve made env variables before, no problem.

Create /etc/profile.local and add the line:

Code: Select all

PATH=$PATH:/root/my-applications/sbin
export PATH
Works great.

Then right below it I have:

Code: Select all

APP_DIR=$(</etc/AppDir.conf)
export APP_DIR
The file does exist.
I know I can export them both in one statement.

The variable survives all the way to the /root/Startup dir.
I put a xmessage there and it shows that $APP_DIR is still alive.

But in rxvt, neither "set" or "env" show the variable.
And typing in rxvt:

Code: Select all

sh-4.1# echo $APP_DIR

sh-4.1# 
Why is it that rxvt doesn`t get my variable?
And exactly where or what does have it?

As said, I`ve made them before no trouble, but now in Lucid-528-005 no go.
Last edited by sunburnt on Mon 18 Jun 2012, 11:35, edited 1 time in total.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#2 Post by jpeps »

maybe you need "export $APP_DIR" ??
Last edited by jpeps on Sun 17 Jun 2012, 08:44, edited 1 time in total.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#3 Post by Karl Godt »

I found out that Variables that have to be visible in Xorg environment, really have to be exported by the /usr/bin/xwin script .

Normally it should be enought as xwin is started normally by /etc/profile . This is a problematic feature, because it relays on the non-existance of /tmp/bootcount.txt file, which actually is a .touch file .

It should go to /var/Puppy/X or /var/Puppy/tmp or /var/puppy/state in my thoughts .

If you logout from X and type xwin again, i could think of that some exports don't work anymore .
I am also not sure about fido or spot . .

I launch xwin from /etc/inittab with :once:/usr/bin/xwin and then i have no /etc/profile parsing before . I do it with "#!/bin/bash --login" bang in xwin script .

Daemons like acpid are another thing . If they should popup an xmessage, i found out that i had to start them from ~/.xinitrc .

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#4 Post by sunburnt »

jpeps; I`m sure it`s "export (variable)"... No $.
As I said, the PATH export works fine, but the identical APP_DIR doesn`t.

The script in /root/Startup shows APP_DIR is good there, but not in rxvt.


Karl; Yikes! The more I learn, the more I see what a mixed bag Linux really is.
Standards... Does anyone know what standards are? :?

I just don`t see why PATH is okay and APP_DIR is not.
I`ll try exporting it in xwin just before the "start X" section.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#5 Post by Karl Godt »

Karl; Yikes! The more I learn, the more I see what a mixed bag Linux really is.
Thierry : Thats for sure ! Am on win atm to fix Puppy :lol:

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#6 Post by sunburnt »

Update: Nope, it didn`t work. I kinda figured it wouldn`t.

Karl; How about making a new Linux distro? Rather than reworking the wheel?

A much simpler one, with no union, no legacy of scattered install files, etc.

I have a modded version of Tiny Core that`s very close to what I have in mind.
Main dirs. are divided into read-only that`re in a Sq. file, read-write on a partition,
and the system dirs. are just as they are in the initrdfs ( mnt, proc, sys, tmp, ...).
I have a dir. tree map that shows what is what.
Most of the main dirs. are links, this allows the O.S. to be rearranged.

### If there`s any interest I`ll post a prospectus about it..


### News... I have my AppDir setup working, I modded it to allow multiple apps.
And I also modded it to work with shared libs. in squash files.
This allows the apps. to load into ram and not have multiple copies of libs.
In many cases I`ve seen, the libs. are much bigger than the app. itself.

I have an AppDir builder script that works okay, more work`s needed.
I have Audacious, mtPaint, Xfe filer, and xMahjongg all working.
As I get more apps. I`ll post the selection and gather more.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#7 Post by Karl Godt »

Have no idea about Tiny Core .

Could you post a link to an .iso for dualcore pcs (dell optiplex 755,4 GB Ram) ?

Would it be
Live cd only, with mounted /tmp always on PUPMODE 2 ?

Interesting idea .

Some use T2 to build Puppy, some use Puppy to build DTLinux .

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#8 Post by jpeps »

I tried this in .bashrc and it worked

Code: Select all

Apps_Dir='/mnt/sda2/Desktop/apps_dir'
set - $Apps_Dir

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#9 Post by amigo »

I think your problem is here:

Code: Select all

APP_DIR=$(</etc/AppDir.conf)
Are you trying to read the file? Is all the code being run with bash or is another shell involved? The above construct will not work with all shells. Try using:

Code: Select all

APP_DIR="`cat /etc/AppDir.conf`"
[/code]

Bruce B

#10 Post by Bruce B »

sunburnt wrote:I just don`t see why PATH is okay and APP_DIR is not.
I don't see why PATH works at all. I thought /etc/rc.local runs before /etc/profile. If so, the PATH statement in profile would not append a previous PATH statement. It would replace it with the new PATH statement.

Curiously

~

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#11 Post by sunburnt »

jpeps; I posted to you, but it didn`t show up here... Odd.! Nope, it didn`t work either.

I wonder why set shows different variables then env does?

Hi amigo; I tried: APP_DIR='/mnt/sdb3/AppLib'
That`s the value in the config. file, still no go when rxvt is run.

Bruce B;
Barry made comment somewhere that the environment variables seem to die at some point in the boot process.


The thing that`s interesting is that one gets through and the other one only makes it to the /etc/Startup folder.

In /etc/Startup I made a script:

Code: Select all

xmessage " Test" ". $APP_DIR ."
It shows that the variable is alive and well, then run the same script file in rxvt and the xMessageBox is empty.
.

Bruce B

#12 Post by Bruce B »

sunburnt wrote:jpeps; I posted to you, but it didn`t show up here... Odd.! Nope, it didn`t work either.

I wonder why set shows different variables then env does?

Hi amigo; I tried: APP_DIR='/mnt/sdb3/AppLib'
That`s the value in the config. file, still no go when rxvt is run.

Bruce B;
Barry made comment somewhere that the environment variables seem to die at some point in the boot process.


The thing that`s interesting is that one gets through and the other one only makes it to the /etc/Startup folder.

In /etc/Startup I made a script:

Code: Select all

xmessage " Test" ". $APP_DIR ."
It shows that the variable is alive and well, then run the same script file in rxvt and the xMessageBox is empty.
.
rxvt is an emulator. If bash is the shell one of the first things it does in Puppy is source ~/.bashrc

You can put source commands to a file containing the instructions to reset the variables that were lost.

This file must be sourced and not in a secondary shell or the env will be lost.

It is a workaround for a problem you have which I cannot explain.

Example:

. /root/.extracommands




~

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#13 Post by jpeps »

Check what shell you're using: "ps | grep $$"

Bruce B

#14 Post by Bruce B »

sunburnt wrote:I wonder why set shows different variables then env does?
set as I know it is an internal bash command. It might behave completely in other shells.

type: help set

env is an external command

type: env --help

~

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#15 Post by jpeps »

Also works: Place a file in /etc/profile.d with desired variables:

ex: /etc/profile.d/MyEnv

APPS_DIR="/mnt/sda2/Desktop/apps_dir"

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#16 Post by Karl Godt »

jpeps wrote:Check what shell you're using: "ps | grep $$"

Code: Select all

echo $0
instead of $$

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#17 Post by Karl Godt »

there are configfiles .Xresources and .Xdefaults .

mrxvt also has a .mrxvtrc configfile i think .

not sure about rxvt/urxvt .

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#18 Post by sunburnt »

SOLVED.!

It seems that I found at least "one" variable that won`t work. Lucky me...

First the variable APP_LIB worked fine, so I got suspicious.
I changed APP_DIR to APPDIR and it works fine.
I`m guessing that App_Dir would probably work also.

There`s a few existing env variables that have _DIRS or DIR in them:

Code: Select all

XDG_CONFIG_DIRS=/etc/xdg
XDG_DATA_DIRS=/usr/share:/usr/local/share
XFINANSDIR=/root/.xfinans
But it doesn`t seem that there would be a name space conflict here.
Odd.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#19 Post by Karl Godt »

maybe it had been

Code: Select all

App _Dir
(space) (typo) ?

Don't know if such things would break login
ie
App _Dir=/path
login App : command not found
.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#20 Post by sunburnt »

No, I rewrote it so many times, it couldn`t have been wrong all of them.
You could try setting APP_DIR in profile.local and see if it does it for you.

The results are consistent, something just doesn`t like _DIR .
The new variables APPDIR and APPLIB work very well.
So I don`t have a broken system after all.
At least not any more broken than Puppy and Linux are already. :wink:

Thanks Karl and everyone... Terry

Post Reply