capturing the o/p to a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting capturing the o/p to a variable
# 1  
Old 01-15-2009
capturing the o/p to a variable

Hi,

#Script mentioned below
txt=($(echo `./demo1.sh`))
p=0
for p in "$txt"
do
col=($(./generateTable /import/data01/sri/Developer/SqlReport/Lab/23/${var[11]} "$p"))
.
.
.
.
done

o/p displayed upon executing a script called "demo1.sh" is as below(two seperate lines):
class=H,pool=row;duration.count,duration.sum
class=E,pool=row;duration.count,duration.sum

Now I want this to be stored in an variable called text.After that I want to parse the variable and take each line as single individual input and continue executing the script inside a for loop.The above script is my script, its working, but its taking only the 1st line and comes out of the loop.


Plz help.Smilie
# 2  
Old 01-15-2009
Quote:
Originally Posted by villain41
txt=($(echo `./demo1.sh`))
Code:
IFS='
'
txt=( $( ./demo.sh ) )

Quote:
p=0
for p in "$txt"
Code:
for p in "${txt[@]}"

# 3  
Old 01-15-2009
Thanks, its working now.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

SED capturing information from a variable

Hi I can't get this line to work. I need to capture what is between Home and plugin_out, where the .* is located. RUN=`echo '${TSP_FILEPATH_PLUGIN_DIR}' | sed -e 's^/results/analysis/output/Home/\(.*\)/plugin_out/g'`; echo ${RUN}; I'm getting the error sed: -e expression #1, char 51:... (1 Reply)
Discussion started by: jdilts
1 Replies

2. Shell Programming and Scripting

[SOLVED] Capturing output in a korn variable

Hi, I'm new to korn and having trouble capturing the text output from one program in an array that I can then feed into another program. Direct approaches didn't work, so I've tried to break it down thus: The program lonlat2pixline gives the values I need in the second column, so I print that... (4 Replies)
Discussion started by: daurin
4 Replies

3. Shell Programming and Scripting

Help with capturing homedir via ssh and saving to variable

I need to capture the homedir using the ssh command and then saving it to a variable. The results from the following command is what I need to capture to a variable: NOTE: the value I'm getting back is also incorrect. as it seems to be getting the home dir from the local server and not the... (2 Replies)
Discussion started by: reneuend
2 Replies

4. Shell Programming and Scripting

capturing a file to store in a variable

I have a file in a windows directory the file is delivery to us like this 07210900.dat where 07210900 is the current date. If I want to store that file in a variable UpLoadFileName and rename, so I can Ftp later to a UNIX directory, I am doing this, is this correct? CDRemoteDir='cd... (0 Replies)
Discussion started by: rechever
0 Replies

5. UNIX for Dummies Questions & Answers

Capturing a value in to variable.

Hi, I currently have a shell script where it captures in the value in to 'TOTAL' and outputs to a file, i want to capture another value of a query in to another variable and output it. Current script: sqlplus -s $user <<EOD | read TOTAL set heading off set pages 0 set feedback off set... (1 Reply)
Discussion started by: ravi0435
1 Replies

6. Shell Programming and Scripting

Losing new lines when capturing output to variable

Explain this? $ ls | grep -e "crd\|cs" crd cs $ CLONES=`ls | grep -e "crd\|cs"`;echo $CLONES; crd cs $ CLONES=`ls | grep -e "crd\|cs"`;echo "$CLONES"; crd cs (1 Reply)
Discussion started by: blasto333
1 Replies

7. Shell Programming and Scripting

Capturing a number at the end of line and store it as variable

Hello, Would someone guide me on how to write a shell script the would search for a phone no using at the end text file using sed or awk and store it in a varaible or print it. The text file is in this form text or numbers in first line text or numbers in second line . . . Firsname... (6 Replies)
Discussion started by: amuthiga
6 Replies

8. UNIX for Dummies Questions & Answers

Capturing some data from a file into a variable

I have a file with some values in a tab delimted format Eg: 'test' contains: a<tab>b<tab>c<tab>Trk_12345678 now i need to capture this value 'Trk_12345678' into a variable say 'x' and append that value of 12345678 to 12345679 and store is back to a new 'test1' file as : 'test1'... (11 Replies)
Discussion started by: shiroh_1982
11 Replies

9. Shell Programming and Scripting

Capturing value into variable

Hi, I am new to shell scripting, I am trying to write a shell script, which will automate the process of mailing the invoices at the end of the day. For major part I am using Oracle database function. The problem is I want to capture the value returned by the Oracle function into the script... (2 Replies)
Discussion started by: prasad01
2 Replies

10. UNIX for Dummies Questions & Answers

capturing the output of grep as integer variable

Hi, I have an expression using grep and nawk that captures the ID number of a given Unix process. It gets printed to screen but I don't know how to declare a variable to this returned value! For example, ps -ef|grep $project | grep -v grep | nawk '{print $2}' This returns my number. How... (2 Replies)
Discussion started by: babariba
2 Replies
Login or Register to Ask a Question