while read and exec based on values


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers while read and exec based on values
# 1  
Old 07-15-2012
while read and exec based on values

hi

i need a ksh to read file and depending on value do something. can anyone help?


thanks
# 2  
Old 07-15-2012
may i know what values do you have in the file you wish to read,Please also tell what you want to execute in responce.
# 3  
Old 07-16-2012
ok

there is a parameter file which has values

A
B

so while reading parm file based on values execute script

for example,

if A, should execute a.sh script
if B,should execute b.sh script

---------- Post updated at 12:13 PM ---------- Previous update was at 12:06 PM ----------

Here this is what I have written so far

#!/usr/bin/ksh
cat /home/param.dat| while read line
do
if [$line -eq "A"] ;
then ./A .ksh
else
if [$line -eq "B"] ;
then
./B.sh
fi
fi
done

It does not work, it gives A not found error and A not found error
# 4  
Old 07-16-2012
Code:
#!/bin/ksh
while read line
do
if [[ "$line" = "A" ]]
then
. /A.sh
elif [[ "$line" = "B" ]]
then
. /B.sh
fi
done < /home/param.dat

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read with two values

I have a script like this: read -e -r -p "enter name of product in CAPS: " ITEM echo -e "Please enter the product number" read -e -r -p "Enter list at date:" list #Here someone enters case6 for ITEM if ]; then ITEMLST=`echo CASESIX`;fi Then I have commands that look for the directory... (3 Replies)
Discussion started by: newbie2010
3 Replies

2. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies

3. Shell Programming and Scripting

Read record from the text file contain multiple separated values & assign those values to variables

I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables. I need to read this file which is an input to my script Config.txt file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies

4. Shell Programming and Scripting

While loop to read values

Hi Everyone, I am currently tasked with some reporting on various Unix based OSes. I have a script deployed that runs and grabs the information I am looking for, and has a bit of logic to output the desired result into a text file. Example of my text file: multiUsers=yes... (1 Reply)
Discussion started by: Zaphod_B
1 Replies

5. UNIX for Dummies Questions & Answers

sum values based on ID

Hi, I would like to be able to sum up the counts of a column by the ID of another column. Example (although the actual file I have has thousands of IDs): Input file: A1BG-AS1:001 3 A1BG-AS1:002 0 A1BG-AS1:003 2 A1CF:001 1038 A1CF:002 105 A1CF:003 115 A1CF:004 137 Desired output... (3 Replies)
Discussion started by: fadista
3 Replies

6. Shell Programming and Scripting

Script Variables Inquiry, Values Okay in Standalone Exec, No-Show in Cron Exec

I have the following bash script lines in a file named test.sh. #!/bin/bash # # Write Date to cron.log # echo "Begin SSI Load $(date +%d%b%y_%T)" # # Get the latest rates file for processing. # d=$(ls -tr /rms/data/ssi | grep -v "processed" | tail -n 1) filename=$d export filename... (3 Replies)
Discussion started by: ginowms
3 Replies

7. Shell Programming and Scripting

Read values from file.

I have a config file of this format: Company= Alpha Tech From Email = AlphaTech@Alphatech.com Pass = Passowrd To Email = abc@hotmail.com Smtp=smtp.live.com:587 I want to read these values from this file and use in a command to send email. I am trying grep but it gives full line. I just... (8 Replies)
Discussion started by: kashif.live
8 Replies

8. Shell Programming and Scripting

AWK: read values from file1; search for values in file2

I have read another post about this issue and am wondering how to adapt it to my own, much simpler, issue. I have a file of user IDs like so: 333333 321321 546465 ...etc I need to take each number and use it to print records wherein the 5th field matches the user ID pulled from the... (2 Replies)
Discussion started by: Bubnoff
2 Replies

9. Shell Programming and Scripting

read column values one after another

hi, Can some one help me how to retrieve column values row by row My requirement is like below : I have a text file having comma seperated values of these records . OName OType SrcDB Sschema targetdb TSchema Load Dataype processY/N aa Table a e i m Y db2 y aa index b c d e N sql N ... (4 Replies)
Discussion started by: sailaja_80
4 Replies

10. Shell Programming and Scripting

How to pick values from column based on key values by usin AWK

Dear Guyz:) I have 2 different input files like this. I would like to pick the values or letters from the inputfile2 based on inputfile1 keys (A,F,N,X,Z). I have done similar task by using awk but in that case the inputfiles are similar like in inputfile2 (all keys in 1st column and values in... (16 Replies)
Discussion started by: repinementer
16 Replies
Login or Register to Ask a Question