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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-01-2006
Registered User
 

Join Date: Feb 2006
Location: Mumbai, India
Posts: 25
Parsing input paramter in a script

Hi folks I am having a little trouble in parsing a variable read into a ksh script

I have a bunch of variables passed into script

test.ksh HOST SERVER JOB1 JOB2 JOB3 JOB4 JOB5

What I want to do is read all the $JOB variables ($JOB1, $JOB2, $JOB3) into a variable and then read that variable in a loop and use the values in a case statement for further use however when I try doing this

if [ $# -lt 3 ]
then
echo
usage()
echo
exit
fi

J=$3,$4,$5,$6,$7,$8
for JOB in $J
do
case $JOB in
BUPD ) echo $JOB ;;
FUPD ) echo $JOB ;;
DMMD ) echo $JOB ;;
BNMD ) echo $JOB ;;
OC10 ) echo $JOB ;;
WRPF ) echo $JOB ;;
STRT ) echo $JOB ;;
CKPS ) echo $JOB ;;
CKRT ) echo $JOB ;;
esac
done

This however is reading all the variables in one

echo $JOB is returing BUPD,FUPD,DMMD,BNMD,OC10,STRT

Can someone help
Sponsored Links
  #2 (permalink)  
Old 02-01-2006
Registered User
 

Join Date: Jan 2005
Posts: 683
Prior to your "for" statement add this line:
typeset IFS=","
  #3 (permalink)  
Old 02-01-2006
Registered User
 

Join Date: Feb 2006
Location: Mumbai, India
Posts: 25
Thanks tmarikle!!

It worked
Sponsored Links
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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell script parsing with sed jjamd64 UNIX for Dummies Questions & Answers 5 12-11-2007 04:51 PM
Help with script parsing a log file mevasquez Shell Programming and Scripting 3 11-15-2007 04:15 PM
parsing problem with script mike@freddiemac Shell Programming and Scripting 5 08-03-2006 04:06 PM
making sure a command line paramter is a number rcunn87 Shell Programming and Scripting 3 07-13-2006 11:36 AM
Asking on taking in and out paramter blueberry80 UNIX for Dummies Questions & Answers 1 07-03-2003 12:03 PM



All times are GMT -4. The time now is 02:58 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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0