12-03-2013
The first argument to a bash shell script is usually assigned to $1. Are you assigning that to your $var variable elsewhere in your script? If you change $var to $1 it works fine.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all,
is it possible to create a 'dynamic' case statement.
ie
select option in `ls`
do
case satement depending on results of the above `ls`
done
I hope I have explained this ok!
Thanks
Helen (1 Reply)
Discussion started by: Bab00shka
1 Replies
2. Shell Programming and Scripting
Hi,
I am writing case statement to execute some finction, my requirement is once one of the case statement is executed again it has to prompt for the option.
for script in `echo "$Script_Selected"`
do
case $script in
1) getNoOFActUsers
;;
2) moveServerrOORotation
;;
... (2 Replies)
Discussion started by: Satyak
2 Replies
3. Shell Programming and Scripting
Hi,
I'm trying to write a routine to parse a file that contains data that will be read
into arrays. The file is composed of labels to identify data types and arbitrary
lines of data with the usual remarks and empty new lines as is common with
config files.
The initial pass is built as so:... (3 Replies)
Discussion started by: ASGR
3 Replies
4. Shell Programming and Scripting
greetings,
I have a script that is taking input like this:
a
b
c
d
aa
bb
aaa
bbb
ccc
ddd
and formating it to be like this:
a b c d
aa bb
aaa bbb ccc ddd (4 Replies)
Discussion started by: adambot
4 Replies
5. Shell Programming and Scripting
I'm pretty sure I already know the answer to this, but I want to make sure I'm not overlooking anything. I'm working on a log monitoring script and every 10 lines I want to display a summary of events. The thing is, there are a lot of possible events, that likely won't have happened, so I only want... (0 Replies)
Discussion started by: DeCoTwc
0 Replies
6. Shell Programming and Scripting
Hello,
The standard case statement :-
case "$1" in
"IE0263")
commands;;
"IE0264")
commands;;
esac
is it possible to have :-
case "$1" in
"IE0263" OR "IE0878")
commands;;
"IE0264")
commands;;
esac
Thanks (4 Replies)
Discussion started by: jmahal
4 Replies
7. Shell Programming and Scripting
I have the following bash script and it is not accepting the lines
"--"|"--""-")
"--""-"")
while
do
echo "Current Argument is ${1}"
case "$1" in
"--"|"--""-")
echo "Argument is ${1}"
shift # Skip ahead one to the next argument.
... (1 Reply)
Discussion started by: kristinu
1 Replies
8. Shell Programming and Scripting
Hey, guys I really need some help with a project.
"Write a shell program that examines the command line arguments, counts and collects the number of options. Basically it has to collect and count the arguments that start with a "-" and the one's that don't start with a -
I know I have to use... (2 Replies)
Discussion started by: sk192010`
2 Replies
9. Shell Programming and Scripting
Hello All,
I am writing a script that is to be placed on multiple servers, and of course I've started
running into some compatibility issues for certain shell commands.
The code below worked just fine on most of my machines except for a couple.
Here I had 4 separate lines in my script that... (3 Replies)
Discussion started by: mrm5102
3 Replies
10. Shell Programming and Scripting
I'm having an issue with bash read input when using a case statement.
The script halts and doesn't read the input on the first loop. if I hit enter then the scripts starts to respond as expected. Need some help here.
defaultans=8hrs
read -e -i $defaultans -p "${bldwht}How long would you like... (5 Replies)
Discussion started by: woodson2
5 Replies
eval(n) Tcl Built-In Commands eval(n)
__________________________________________________________________________________________________________________________________________________
NAME
eval - Evaluate a Tcl script
SYNOPSIS
eval arg ?arg ...?
_________________________________________________________________
DESCRIPTION
Eval takes one or more arguments, which together comprise a Tcl script containing one or more commands. Eval concatenates all its argu-
ments in the same fashion as the concat command, passes the concatenated string to the Tcl interpreter recursively, and returns the result
of that evaluation (or any error generated by it). Note that the list command quotes sequences of words in such a way that they are not
further expanded by the eval command.
EXAMPLES
Often, it is useful to store a fragment of a script in a variable and execute it later on with extra values appended. This technique is
used in a number of places throughout the Tcl core (e.g. in fcopy, lsort and trace command callbacks). This example shows how to do this
using core Tcl commands:
set script {
puts "logging now"
lappend $myCurrentLogVar
}
set myCurrentLogVar log1
# Set up a switch of logging variable part way through!
after 20000 set myCurrentLogVar log2
for {set i 0} {$i<10} {incr i} {
# Introduce a random delay
after [expr {int(5000 * rand())}]
update ;# Check for the asynch log switch
eval $script $i [clock clicks]
}
Note that in the most common case (where the script fragment is actually just a list of words forming a command prefix), it is better to |
use {*}$script when doing this sort of invocation pattern. It is less general than the eval command, and hence easier to make robust in |
practice. The following procedure acts in a way that is analogous to the lappend command, except it inserts the argument values at the
start of the list in the variable:
proc lprepend {varName args} {
upvar 1 $varName var
# Ensure that the variable exists and contains a list
lappend var
# Now we insert all the arguments in one go
set var [eval [list linsert $var 0] $args]
}
However, the last line would now normally be written without eval, like this: |
set var [linsert $var 0 {*}$args] |
SEE ALSO
catch(n), concat(n), error(n), interp(n), list(n), namespace(n), subst(n), tclvars(n), uplevel(n)
KEYWORDS
concatenate, evaluate, script
Tcl eval(n)