The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Setting up variables solar_ext UNIX for Dummies Questions & Answers 3 03-28-2008 11:50 AM
dynamically setting an array ragha81 Shell Programming and Scripting 4 02-07-2008 03:54 AM
Getting variables into a array. vivsiv Shell Programming and Scripting 2 02-06-2008 03:45 PM
Setting values in an array? Easy one TheCrunge Shell Programming and Scripting 3 11-29-2005 05:46 PM
Array variables kavitha Shell Programming and Scripting 2 03-23-2004 10:16 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-20-2008
wolfhurt wolfhurt is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 8
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 (permalink)  
Old 05-20-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,794
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]}

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0