Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

AIX 6.1, setting env vars

Posted on 2011-09-21
4
Medium Priority
?
618 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
Suggested Courses

885 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