Plan9 Environment Variables -- Notes of Introduction to OS Abstractions Using Plan 9 from Bell Labs(III)
2011-02-27 23:28
387 查看
The
interface for using environment variables in Plan 9 is a file
interface.
All interfaces of environment variables can be found
under /env.
To
obtain the value for a environment variable, from a C program, we can
use the getenv
system call. If the variable is not defined, getenv
returns a null string. A related call is putenv,
which accepts a name and a value, and set the corresponding
environment variable accordingly.
In
some cases it is convenient to define an environment variable just
for a command. This can be
done by defining it in the same command
line, before the command, like in the following exam-ple:
Useful
Environment Variables:
status
is updated by the shell once it finds out how it went to the last
command it executed.
path
is a list of paths where the shell should
look for executable files
to run the user commands.
user
contains the user name
.
sysname
contains the machine name.
The
file /dev/text represents
the
text shown in the window (when used within that window). To make
a copy of your shell session,
you already know what to do:
;
cp /dev/text $home/saved
The
same can be done for the image shown in the display for your window,
which is also represented as a file, /dev/window.
This is what we did to capture screen images .
interface for using environment variables in Plan 9 is a file
interface.
All interfaces of environment variables can be found
under /env.
To
obtain the value for a environment variable, from a C program, we can
use the getenv
system call. If the variable is not defined, getenv
returns a null string. A related call is putenv,
which accepts a name and a value, and set the corresponding
environment variable accordingly.
#include <u.h> #include <libc.h> void main() { char * path; path=getenv("path"); if(path==nil) sysfatal("path not defined!"); print("PATH is %s /n", path); exits(nil); }
In
some cases it is convenient to define an environment variable just
for a command. This can be
done by defining it in the same command
line, before the command, like in the following exam-ple:
; temp=/tmp/foobar echo $temp /tmp/foobar ; echo $temp ;
Useful
Environment Variables:
status
is updated by the shell once it finds out how it went to the last
command it executed.
path
is a list of paths where the shell should
look for executable files
to run the user commands.
user
contains the user name
.
sysname
contains the machine name.
The
file /dev/text represents
the
text shown in the window (when used within that window). To make
a copy of your shell session,
you already know what to do:
;
cp /dev/text $home/saved
The
same can be done for the image shown in the display for your window,
which is also represented as a file, /dev/window.
This is what we did to capture screen images .
相关文章推荐
- Plan9 Files -- Notes of Introduction to OS Abstractions Using Plan 9 from Bell Labs(IV)
- Notes of Introduction to OS Abstractions Using Plan 9 from Bell Labs(II)
- Notes of Introduction to OS Abstractions Using Plan 9 from Bell Labs(I)
- Porting of cURL to Android OS using NDK (from The Software Rogue)
- Using MATLAB to analyze principal components obtained from a molecular dynamics simulation of a pro
- How to update multiple columns of one table using values from another table?
- How to get the Values of Selected Row from a Gridview using ASP.NET
- Using freewheel.labs.autodesk.com to auto generate preview images of DWF files on your web site
- A brief introduction to XenBus from the perspective of the driver
- From double Click to Main: The initialization of Process in OS
- From double Click to Main: The initialization of Process in OS
- some list operation(#quote from MIT 'introduction to computation and programming using python, Revis
- Introduction to Using the XML DOM from Visual C++
- 102.You want to import schema objects of the HR user using Oracle Data Pump from the development dat
- Introduction to Using the XML DOM from Visual C++
- Using a palette from .NET to display properties of multiple AutoCAD objects
- How To Change the Partition Column Of A Partitioned Table Using DBMS_Redefinition [ID 846405.1]
- introduction to computation and programming using python
- CodeSnip: How to Get Id of the Record Using ASP.NET and SQL Server 2000
- From feature descriptors to deep learning: 20 years of computer vision