Solved

AIX 6.1, setting env vars

Posted on 2011-09-21
4
556 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sudo logging 5 79
Restore XenServer VM with only dd image of LVM snapshot 3 157
Linux : adding the new user with password option, 11 97
MarkLogic 1 67
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

948 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

22 Experts available now in Live!

Get 1:1 Help Now