Re: Korn and csh variables issue



nishant80@xxxxxxxxx writes:

Is there a common way of defining a variable that will work in both
korn shell and C shell?

Well.... You could define them as environment variables, and THEN execute the shell.
for instance, this is done in /etc/profile, which is executed before the login shell.

I need to have a common way because I am using a separate file to
define some variables that will be used by multiple korn and csh
scripts.

I'd suggest you create two files

file.ksh
file.csh

and for ksh, execute
. file.ksh
for csh, execute
source file.csh

As another suggestion, you can create an alias or function. For
instance, in csh, you can use

alias setvar 'set \!:1 = \!:2'

and for ksh/bash you can define a function:

setvar() {
eval $1=$2
}

then the command

setvar a 123

would work for both.

But, IMHO, if you can do that, then you might as well define the
variables at the same time.

NOTE: This is not an environment variable. That would require the following modifications:

#csh
alias setvar 'setenv \!:1 \!:2'

#ksh
setvar() {
eval export $1=$2
}



--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.
.



Relevant Pages

  • Re: some queris on .profile file
    ... then some-script.sh is sourced into current running shell, ... Single dot is equivalent to source'ing some script, ... If I have execute .profile then the command would be ... local variables, environment variables, shell options, aliases, ...
    (comp.unix.tru64)
  • Re: Why does give this message?
    ... > You have a quoting problem somewhere. ... > you attempt to execute, and see if you can spot anything. ... So check the environment variables too, or better yet, don't go thru a ... shell to call your sub-programs. ...
    (comp.unix.programmer)
  • Re: Redirection issue
    ... 1- execute input commands from standard input, ... the phrase "it does not work anymore" carries very little meaning. ... after compilation and execution of the shell with a simple command like ...
    (comp.lang.c)
  • vulnerabilities in scponly
    ... without allowing shell access. ... scponly makes no effort to verify the path to the scp or sftp-server ... arbitrary commands by simply uploading a file. ... However, if this is *NOT* the case, the user could execute arbitrary ...
    (Bugtraq)
  • RE: Shell Shoveling?!?
    ... Subject: Shell Shoveling?!? ... you need to somehow execute code on the box. ... > 2) wouldn't there be a requirement to escalate privileges in order ... > to run NetCat on the compromised host? ...
    (Pen-Test)

Loading