06-28-2010
I think CSH uses "setenv" to set environment variables.
This User Gave Thanks to bartus11 For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I am trying to put the csh variable into a perl.
In the below case, i am trying to put the csh variable "var" into my perl code. I tried to use '"$var"' but i don;t think it works.
Can anybody help me pls?
#!/bin/csh
set var = `echo "xxx"`
perl myperlcode.pl file
... (9 Replies)
Discussion started by: Raynon
9 Replies
2. Shell Programming and Scripting
Hi frind,
i="1"
while
do
echo "i is $i"
data_file=$HYP_ROOT/import/efcextr$i.txt
echo "$data_file"
i=`expr $i + 1`
done
This is woring finly in ksh but not in ksh.
in ksh it showing error
i=1: Command not found
i: Undefined variable
Kindly help me ...why it is showing the error... (1 Reply)
Discussion started by: deep_kol
1 Replies
3. UNIX for Dummies Questions & Answers
By using a csh, I want to address a variable content whose name is/matches the content of a given other variable.
i.e.
set name=´sam´
set ${name}_age=´27´
So, by typing: echo ${name}_age
I correctly obtain: sam_age
By typing: echo $sam_age
or echo ${sam_age}
I correctly obtain: 27
... (1 Reply)
Discussion started by: sobolev
1 Replies
4. Shell Programming and Scripting
May God never give you the bane of working on Solaris.
Now, I am trying to run this simple shell script:
#!/bin/sh
input="a
b
c"
data="123"
while read eachline
do
data="$data$eachline"
done << EOF
$(echo "$input")
EOF... (2 Replies)
Discussion started by: pavanlimo
2 Replies
5. UNIX for Dummies Questions & Answers
Guys,
following is my issue:
------------------------
#!/bin/csh
# specify a counter
@ k = 1
# loop
while ($k < 3)
# read all text file with a specific number less than 3 in the last column of a record
foreach file ( *.txt)
# capture the line by passing the column... (1 Reply)
Discussion started by: znbhatti
1 Replies
6. Shell Programming and Scripting
My shell is csh and it is required.
I have a file like sample.txt
------------------------
a b c
d
e
f
g h i
------------------------
I want set the file to a variable and print it out in the same format.
I have tried something like this, but not succed.
% cat ~/tmp/sample.txt
a b c
d... (8 Replies)
Discussion started by: anykao
8 Replies
7. Shell Programming and Scripting
Hi All,
I want to check existence of variable, whose name gets decided dynamically.
E.g. value of this variable,is derived as $option_"exclude" , where value of option varies depending upon user input.
I am trying to do it in a following way :
set exclude_var = `echo $option"_exclude"`... (3 Replies)
Discussion started by: Rashmee
3 Replies
8. Shell Programming and Scripting
First post on here. So I use csh shells for my research (physics... not a CS person). I am trying to rerun the same scripts, but there are ~10 files that have similar variables that I have to change for each different configuration, so I would like one central file for the variables I change that... (3 Replies)
Discussion started by: sabrepride
3 Replies
9. Shell Programming and Scripting
Hi,
I have been trying to do a little script in Csh, to classify some information of a text document.
My problem appears when i have to calssificate two parts of the same line into different variables, for example in the document appears something like that:
ID NAME
999999,Michel... (1 Reply)
Discussion started by: losbirras
1 Replies
10. Shell Programming and Scripting
We are using csh on our AIX platform, if we have to export/set a specific environment variable we use setenv command but its only valid till session.
How do we set that variable permanent in our csh AIX? Do we put it in userprofile file or something else? (1 Reply)
Discussion started by: aixusrsys
1 Replies
LEARN ABOUT MOJAVE
getenv
GETENV(3) BSD Library Functions Manual GETENV(3)
NAME
getenv, putenv, setenv, unsetenv -- environment variable functions
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdlib.h>
char *
getenv(const char *name);
int
setenv(const char *name, const char *value, int overwrite);
int
putenv(char *string);
int
unsetenv(const char *name);
DESCRIPTION
These functions set, unset and fetch environment variables from the host environment list.
The getenv() function obtains the current value of the environment variable, name. The application should not modify the string pointed to
by the getenv() function.
The setenv() function inserts or resets the environment variable name in the current environment list. If the variable name does not exist
in the list, it is inserted with the given value. If the variable does exist, the argument overwrite is tested; if overwrite is zero, the
variable is not reset, otherwise it is reset to the given value.
The putenv() function takes an argument of the form ``name=value'' and is equivalent to:
setenv(name, value, 1);
The string pointed to by string becomes part of the environment. A program should not alter or free the string, and should not use stack or
other transient string variables as arguments to putenv(). The setenv() function is strongly preferred to putenv().
The unsetenv() function deletes all instances of the variable name pointed to by name from the list. Note that only the variable name (e.g.,
"NAME") should be given; "NAME=value" will not work.
RETURN VALUES
The getenv() function returns the value of the environment variable as a NUL-terminated string. If the variable name is not in the current
environment, NULL is returned.
The setenv(), putenv(), and unsetenv() functions return the value 0 if successful; otherwise the value -1 is returned and the global variable
errno is set to indicate the error.
ERRORS
[EINVAL] The function getenv(), setenv() or unsetenv() failed because the name is a NULL pointer, points to an empty string, or
points to a string containing an ``='' character.
The function putenv() failed because string is a NULL pointer or string is without an ``='' character.
[ENOMEM] The function setenv(), unsetenv() or putenv() failed because it was unable to allocate memory for the environment.
LEGACY SYNOPSIS
#include <stdlib.h>
void
unsetenv(const char *name);
unsetenv() doesn't return a value.
COMPATIBILITY
putenv() no longer copies its input buffer. This often appears in crash logs as a crash in getenv(). Avoid passing local buffers or freeing
the memory that is passed to putenv(). Use setenv(), which still makes an internal copy of its buffers.
unsetenv() no longer parses the variable name; e.g., unsetenv ("FOO=BAR") no longer works. Use unsetenv("FOO"). unsetenv() also now returns
a status value and will set errno to EINVAL if name is not a defined environment variable.
SEE ALSO
csh(1), sh(1), execve(2), compat(5), environ(7)
STANDARDS
The getenv() function conforms to ISO/IEC 9899:1990 (``ISO C90''). The setenv(), putenv() and unsetenv() functions conforms to IEEE Std
1003.1-2001 (``POSIX.1'').
HISTORY
The functions setenv() and unsetenv() appeared in Version 7 AT&T UNIX. The putenv() function appeared in 4.3BSD-Reno.
BUGS
Successive calls to setenv() that assign a larger-sized value than any previous value to the same name will result in a memory leak. The
FreeBSD semantics for this function (namely, that the contents of value are copied and that old values remain accessible indefinitely) make
this bug unavoidable. Future versions may eliminate one or both of these semantic guarantees in order to fix the bug.
BSD
June 20, 2007 BSD