KSH Setting multiples variables with an array


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting KSH Setting multiples variables with an array
# 1  
Old 05-20-2008
KSH Setting multiples variables with an array

ih all,

Code:
        [...]
        info=$(get_Info $daemon)
        # $info give :
        # "ev20 8800 TTIOGC 12345 astos EDITEUR 0 0 . ."

        server=$(echo $info | cut -d" " -f1)
        port=$(echo $info | cut -d" " -f2)
        dname=$(echo $info | cut -d" " -f3)
        dport=$(echo $info | cut -d" " -f4)
        statu1=$(echo $info | cut -d" " -f7)
        statu2=$(echo $info | cut -d" " -f8)
        spid=$(echo $info | cut -d" " -f9)
        dpid=$(echo $info | cut -d" " -f10)

each element which $info return need to be set in a suite of variables
is there any better way to setting this variables ?
similar as a :
# server, port, dname = get_Infos $daemon

i think that awk can do that but i cant find how...

thank for your helping,
# 2  
Old 05-20-2008
Here is a start:

Code:
#!/bin/ksh
[.....]
        info=$(get_Info $daemon)
        # $info give :
        # "ev20 8800 TTIOGC 12345 astos EDITEUR 0 0 . ."

        server=1
        port=2
        dname=3
        dport=4
        statu1=5
        statu2=6
        spid=7
        dpid=8
        echo "server = ${arr{server]}
        echo "dport = ${arr[dport]}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dialog , capture multiples inputs in variables

Hi everyone , i am trying to do a shell script with dialog , but i have a problem capturing each input variable to then use "echo" to write those inputs on specific orders in a file . If i use this code : dialog --backtitle "Dialog Form Example" --title "Dialog - Form" \ --form "\nDialog... (1 Reply)
Discussion started by: pedropt
1 Replies

2. Shell Programming and Scripting

multiples menu in ksh

Hi, IS possible in ksh to make multiples menus? For example: My menu. 1)Option1 1.1)Option1.1 2.3)Option1.2 2)Option2 2.1)Option2.1 . . . x)Exit I've tried with case but no success. Thanks in advance. (3 Replies)
Discussion started by: iga3725
3 Replies

3. UNIX for Dummies Questions & Answers

Need help with setting up environment variables

hi all, I would appreciate if some one could explain me the difference between setting up the variables as shown below HOME=${HOME:-"/home/user1"} HOME=/home/user1 (1 Reply)
Discussion started by: SSSB
1 Replies

4. UNIX for Dummies Questions & Answers

setting enviroment variables help

Hello everyone, I am currently trying to program in java in unix platform for the first time, so far it is OK as long as I use class libraries which come with java distribution. Unfortunately when I try to use external libraries I have to use -classpath option which I rather not doing all the... (1 Reply)
Discussion started by: run123
1 Replies

5. UNIX for Dummies Questions & Answers

Setting up variables

Hi all, I have a shell script that sets up the environment for an application running on UNIX - ksh. This script is run using: . ./script_name XX where XX is a parameter. I want to run it from another shell script but when I do it I don't get the envornment variables set up and the prompt... (3 Replies)
Discussion started by: solar_ext
3 Replies

6. UNIX for Advanced & Expert Users

setting some variables

i have a file .NAMEexport MY_NAME=JOE when i do this at the command prompt #. .NAME $echo MY_NAME $JOEi created a script called Run.sh . .NAME At the command prompt i did #sh Run.sh #echo $MY_NAMEit returns nothing. What have i missed out? (7 Replies)
Discussion started by: new2ss
7 Replies

7. Shell Programming and Scripting

Setting variables in a function

I'm not quite sure what I'm doing wrong here. I've go several jobs which print reports. Occassionally a printer will break down and reports need to be move to another printer. Rather than hard code the printer names in our scripts I'm trying to set these programatically using our function... (1 Reply)
Discussion started by: BCarlson
1 Replies

8. AIX

Setting Variables not working

Hi all, I am trying to set up some variables in a shell script. The variables contain values of various paths needed to run a java module. The problem is the variables dont seem to be setting at all. here is what i am trying to do : JAR_HOME=/home/was5/bdcms/scheduledjobs/lib export... (1 Reply)
Discussion started by: rpandey
1 Replies

9. Shell Programming and Scripting

cat setting variables

hi All I have a file that has 4 lines: 1. yesterday's date (mm/dd/yyyy) 2. yesterday's day- dd 3. yesterday's month- mm 4. yesterday's year- yyyy I want to read this file and place them in variables. how can I do this. Please help. thanks in advance!! KS (3 Replies)
Discussion started by: skotapal
3 Replies

10. UNIX for Dummies Questions & Answers

setting environment variables ???

Hello, I want to set some environment variables with this script: ip=$@ echo Remote Computer: $ip PERLDB_OPTS="CallKomodo=$ip:9000 RemotePort=$ip:9010 PrintRet=0" export PERLDB_OPTS PERL5LIB=/opt/komodo export PERL5LIB echo PERLDB_OPTS: $PERLDB_OPTS echo PERL5LIB: $PERL5LIB But it... (5 Replies)
Discussion started by: Gargamel
5 Replies
Login or Register to Ask a Question