Solved

AIX 6.1, setting env vars

Posted on 2011-09-21
4
569 Views
Last Modified: 2013-11-17
I am trying to set an env var in AIX

I set the variable TEST, but it does not show up as being set

$ echo $TEST

$ set TEST=one
$
$ set
AUTHSTATE=files
........
_=TEST=one
$
$ echo $TEST

$ echo $PATH
/opt/IBM/mqsi/7.0/jre16/bin:/opt/IBM/mqsi/7.0/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/var/mqm/bin:/usr/bin/X11:/sbin:.

Open in new window


What does this line mean:

_=TEST=one

Open in new window


What am I doing wrong?

Thanks
0
Comment
Question by:Los Angeles1
  • 3
4 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 36575462
Hi,

the variable "_"  indicates the value of the parameter of the last set command issued.

It doesn't have any meaning for the actual environment (in a user's perspective).

Explanation: set is meant  to set positional parameters.

set TEST=one

will set the positional variable $1 to "TEST=one" (and $_, for that matter).

Check this with "echo $1"  and also "echo $_"

A special case is "set" when issued without any arguments. This displays the names and values of all KornShell variables, sorted by name.

Don't use "set" for defining variables.

Use just

VAR=value

for the current shell and

export VAR=value

for the current shell and its subshells (e.g. scripts called from the current shell).


wmp
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36575500
Try this to make it (perhaps) a bit clearer:


set A B C

echo $1
echo $2
echo $3

echo $_

OK?


0
 

Author Closing Comment

by:Los Angeles1
ID: 36575567
Thanks, that was perfect.  Everything is working great, and I seet the $1, etc
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36575577
>> doesn't have any meaning ... << 

It depends.

A net trick is using $_ to find the last field in a line.

Assume that you want to know the value of the 15 minute load average:

set $(uptime); echo $_

Not very common, but ...
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now