---------- Message transmis ---------- Subject: Re: [SLE] how to export a variable when in xterm (in bash script in xterm) Date: Sat, 17 Aug 2002 15:05:21 +0200 From: Alain Barthélemy <bartydeux@gminformatique.com> To: zentara <zentara@zentara.net> Le Samedi 17 Août 2002 13:54, vous avez écrit :
On Sat, 17 Aug 2002 13:26:56 +0200
Alain Barthélemy <bartydeux@gminformatique.com> wrote:
Somebody told of /home/user/.bash_profile but it does not exist in SuSE-7.3. Which file to use to define a global variable in a Bash shell.
In your home directory look for the hidden file .bashrc
Put a line in there like export EDITOR = /usr/bin/joe
and now every NEW xterm will have that in it's environment variables.
You can setup custom bashrc's too. Make a .bashrc1, and .bashrc2, (you can name the files anything you want). Then start an xterm, and it will have the variables from the default .bashrc. Now type "source .bashrc1". Now the xterm has the variables from .bashrc1, but only that xterm, and only until you kill off the xterm.
If you just need to change an environmental variable in the current xterm: export EDITOR=/usr/bin/vim now the $EDITOR ,for that xterm only, is vim, until you kill off the xterm.
Thank you but my problem is not to install another default text editor I'll try to be concrete - I am in a Window Manager (blackbox) - I run a script - in the script there is the lines echo echo "Last scanned file: $LASTFILE" echo echo "Enter new filename: " read fich if not null of course LASTFILE=$fich ..... LASTFILE=$fich export LASTFILE - Thus $LASTFILE "should" be a global variable. - if I leave now the script and type in console: echo "$LASTFILE" I should read: "name_of_fich_I_entered_in_my_script" because $LASTFILE should be a global variable (===> export LASTFILE <====) - but I only read ann old value of $LASTFILE - now - if I type in console mode: - LASTFILE=whatever - export LASTFILE and run my script with the line: echo "$LASTLINE" I read: whatever Thus, the variable is well exported when I type the instruction in console mode (thus in a xterm of course) but not when the same lines are executed via a bash script Now if I leave the X environment (out blackbox thus)and type, on console mode: echo "$LASTLINE" ====> nothing, nothing, nothing Thus a global variable in a xterm console is not the same global variable in console mode with the same user. Thus how to uniformize all these environments and have them talk the same language. -- Alain Barthélemy cassandre@gminformatique.com bartydeux@gminformatique.com http://bartydeux.gminformatique.com -------------------------------------------------------