In your original example the variable i was assigned the whole record (e.g. val1:env1:opt1). In the code that zaxxon suggested, the components val1 env1 opt1 were broken out and assigned to variables A, B and C. There would be no need to reference i, as there wasn't anything assigned to i anyway. You should be able to use A, B, and C as is.
From your original post, you also do a lot of extra work to only read a subset of lines from the input file. That isn't handled by zaxxon's example. Moving along the same lines as was offered, the following code will generate just the lines between START and STOP (inclusive) and assign them to the variables f1, f2, and f3 (A, B, C).
I'm trying to pass a filename, or all the files in the current directory to the ls command with a script. Unsuccessful so far, here are a few of my attempts:
#!/bin/ksh
read fname
#if (( $# > 0 )); then
$fname | ls -l
#fi
this produces a long listing of all the files in my current... (4 Replies)
Hi, so Im a bit new to shell scripting and want to do the following but not sure how. Basically I have a file named "output" which contains misc text but inside the file I want to set up variables like $1 or some symbol. Anyways, in another file called "list" I have a list of items that I want to... (11 Replies)
Hi,
I have a script which adds the user credentials to an ldap server. Im passing the variables as below..
/path/my_script $uname $pwd $environ ${deposit}
If i enter some special characters like ';' in $pwd, script returns an error which is set to display if the user enters... (5 Replies)
Hi
I have a script to which I pass multiple arguments, for example lets say the script name is "abc". I run the script like
./abc def /file <directory location>
In the above "def" is the first argument and "/file" is the second argument. I expect <directory location> that is passed after... (4 Replies)
I have a shell script which is invoked by passing an argument. The outer shell script calls another subshell and I want the argument passed down to flow down to the subshell.
E.g
Invoking a shell ======>> abc_refresh.ksh NM
Below is the content of abc_refresh.ksh
Value1=$1... (7 Replies)
I need to pass arguments to a shell script.My batch is calling some java program.
#################
x=$1
y=$2
java -classpath program
###################
if first parameter and second parameter is null then
java -classpath program
if first parameter is not null and second parameter is... (3 Replies)
I have noticed this thing using csh when passing arguments
Suppose I call a csh script using
../Scripts/plot-model.csh -vmod="npt02-z30.vmod" -R="0/80/0/30" -c="0/4.5" -aspr="1:10"
Somehow the " get removed when doing
$argv
ending up with
-vmod=npt02-z30.vmod... (0 Replies)
hi All,
i am trying to pass arguments that contain space , value will be stored in variables to be used further in script , i went thru previous posting , still its not clear to how to implement for my case.
passing 3 args
test.sh it is 'fun to work in unix'
inside shell
... (3 Replies)
I have a script test.sh which reads various inputs from a user.
#!/bin/ksh
read x
read y
read z
echo x: $x y: $y z: $z
# read few more things again
read a
read b
echo a: $a b: $b
When i run this script as
test.sh << EOF
1
2
EOF (3 Replies)
Hi,
I am using awk here.
Inside an awk script, I have a variable which contains a very long XML data in string format (500kb).
I want to pass this data (as argument) to curl command using system function.
But getting Too many arguments error due to length of string data(payloadBlock).
I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies
LEARN ABOUT SUSE
tk::optionmenu
Optionmenu(3) User Contributed Perl Documentation Optionmenu(3)NAME
Tk::Optionmenu - Let the user select one of some predefined options values
SYNOPSIS
use Tk::Optionmenu;
$opt = $w->Optionmenu(
-options => REFERENCE_to_OPTIONLIST,
-command => CALLBACK,
-variable => SCALAR_REF,
);
$opt->addOptions( OPTIONLIST );
# OPTION LIST is
# a) $val1, $val2, $val3,...
# b) [ $lab1=>$val1], [$lab2=>val2], ... ]
# c) combination of a) and b), e.g.,
# val1, [$lab2=>val2], val3, val4, [...], ...
DESCRIPTION
The Optionmenu widget allows the user chose between a given set of options.
If the user should be able to change the available option have a look at Tk::BrowseEntry.
OPTIONS -options
(Re)sets the list of options presented.
-command
Defines the callback that is invokes when a new option is selected.
-variable
Reference to a scalar that contains the current value of the selected option.
-textvariable
Reference to a scalar that contains the text label of the current value of the selected option.
METHODS
addOptions
Adds OPTION_LIST to the already available options.
EXAMPLE
use Tk;
my $mw = MainWindow->new();
my ($var, $tvar);
my $opt = $mw->Optionmenu(
-options => [[jan=>1], [feb=>2], [mar=>3], [apr=>4]],
-command => sub { print "got: ", shift, "
" },
-variable => $var,
-textvariable => $tvar
)->pack;
$opt->addOptions([may=>5],[jun=>6],[jul=>7],[aug=>8]);
my $f = $mw->Frame(-relief=>'groove', -borderwidth => 2)->pack;
$f->Label(-textvariable=>$tvar)->pack(-side => 'left');
$f->Label(-text => " -> ")->pack(-side => 'left');
$f->Label(-textvariable=>$var)->pack(-side => 'left');
$mw->Button(-text=>'Exit', -command=>sub{$mw->destroy})->pack;
MainLoop;
SEE ALSO
Tk::Menubutton, Tk::BrowseEntry
perl v5.12.1 2007-05-05 Optionmenu(3)