Hi All,
I'm running some encrypted data through a script I wrote. In order to do this, I'm using eval to resolve some of my variables. At the moment, when I use eval to resolve, it strips out some of my encrypted values, and totally drops some others. For example if I have the value ab1"3 it drops... (1 Reply)
Hi, I have two files "foo" and "bar"
$ cat foo
a is \$a and b is \$b
$ cat bar
car tree
using the below 'while' loop I expect the output to be: a is car and b is tree
while read a b; do
eval echo $(cat foo) # o/p: a is $a and b is $b
eval "echo $(eval "cat foo")"... (1 Reply)
Hi,
I have snippet like the following
x="1"
prompt1="hi"
if I say
eval echo \$prompt$x then it is giving o/p "hi"
if I say `eval echo \$prompt$x` here it is giving 1 !
if I add one more escape character i.e.
`eval echo \\$prompt$x` then it is giving "hi"
Can you please... (3 Replies)
I am trying to expand the variable $user in my alias command and tried
several variations of eval but can't seem to get it to work.
The end result should be either:
oracle_user='sudo su - oracle ' or oracle_user='sudo su - oracle1 '
user=$(grep '^oracle:' /etc/passwd | cut... (5 Replies)
hi all,
Am trying to add some code to a ksh script and i dont understand how an eval function is used :
_var=$1
_conceal=$2
eval _val=\$${_var}
can someone shed some light on what the eval function in the above context means/does ??
thanks. (4 Replies)
Hi all,
some small script with eval turned me to crazy.
my OS is linux
Linux s10-1310 2.6.16.53-0.8.PTF.434477.3.TDC.0-smp #1 SMP Fri Aug 31 06:07:27 PDT 2007 x86_64 x86_64 x86_64 GNU/Linux
below script works well
#!/bin/bash
eval ssh remotehost date
eval ssh remotehost ls
below... (1 Reply)
exec(1) User Commands exec(1)NAME
exec, eval, source - shell built-in functions to execute other commands
SYNOPSIS
sh
exec [argument...]
eval [argument...]
csh
exec command
eval argument...
source [-h] name
ksh
*exec [arg...]
*eval [arg...]
DESCRIPTION
sh
The exec command specified by the arguments is executed in place of this shell without creating a new process. Input/output arguments may
appear and, if no other arguments are given, cause the shell input/output to be modified.
The arguments to the eval built-in are read as input to the shell and the resulting command(s) executed.
csh
exec executes command in place of the current shell, which terminates.
eval reads its arguments as input to the shell and executes the resulting command(s). This is usually used to execute commands generated as
the result of command or variable substitution.
source reads commands from name. source commands may be nested, but if they are nested too deeply the shell may run out of file descrip-
tors. An error in a sourced file at any level terminates all nested source commands.
-h Place commands from the file name on the history list without executing them.
ksh
With the exec built-in, if arg is given, the command specified by the arguments is executed in place of this shell without creating a new
process. Input/output arguments may appear and affect the current process. If no arguments are given the effect of this command is to mod-
ify file descriptors as prescribed by the input/output redirection list. In this case, any file descriptor numbers greater than 2 that are
opened with this mechanism are closed when invoking another program.
The arguments to eval are read as input to the shell and the resulting command(s) executed.
On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways:
1. Variable assignment lists preceding the command remain in effect when the command completes.
2. I/O redirections are processed after variable assignments.
3. Errors cause a script that contains them to abort.
4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari-
able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not
performed.
EXIT STATUS
For ksh:
If command is not found, the exit status is 127. If command is found, but is not an executable utility, the exit status is 126. If a redi-
rection error occurs, the shell exits with a value in the range 1-125. Otherwise, exec returns a zero exit status.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO csh(1), ksh(1), sh(1), attributes(5)SunOS 5.10 17 Jul 2002 exec(1)