Command Logic


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Command Logic
# 1  
Old 05-29-2013
Command Logic

Hi,

I need the logic to utilize the command output to be feeded over to successive commands,

for example :

Code:
$ dtconf list-ls-data-sources -h hostname -P 636 -w ~/pwd.txt
DATA MASTER 1
DATA MASTER 2
DATA CONSUMER 1
DATA CONSUMER 1
DATA CONSUMER 1

Based on above output, i would like to utilize values like "DATA MASTER 1", "DATA MASTER 2".... in successive commands.

Is it possible to do one single command?

Thanks. JPrince
# 2  
Old 05-29-2013
You could try:
Code:
dtconf list-ls-data-sources -h hostname -P 636 -w ~/pwd.txt |
while read val; do
  echo Try some command with "$val" 
done


Last edited by Scrutinizer; 05-29-2013 at 08:05 PM..
# 3  
Old 05-29-2013
Thanks for the reply.

However, I am getting the following error while running a test command :

$ ls | while read val ;echo Try some command with "$val" ; done
-bash: syntax error near unexpected token `done'[/CODE]
# 4  
Old 05-29-2013
Please use code tags as required by forum rules!

If running into a "done", the shell expects to have encountered a "do" before. Read the man page of your shell!
Put a do in front of the read
# 5  
Old 05-29-2013
Still getting the same error.

Code:
$ ls | while do read "val" ;echo Try some command with "$val" ; done
-bash: syntax error near unexpected token `do'

# 6  
Old 05-29-2013
In your code, the "do" belongs just after the semicolon.

Regards,
Aliste
# 7  
Old 05-29-2013
I corrected the left out "do" in my post...
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find command with complex logic

I'm looking to write a script that will do a find of directories and delete them if they are older than x days but keep the last x # of folders even if they are older than x days. The usage is for a deployment location, so we want to keep the location clean but retain maybe the last 2 builds that... (5 Replies)
Discussion started by: MaureenT
5 Replies

2. UNIX for Dummies Questions & Answers

Need help in logic using awk command

I have task to find out the min,max, average value of each service for example i searched for " StatementService " $awk '/VST.*StatementService:/{print $3,$4,$19,$22,$25}' performance.log > smp.log $cat smp.log amexgtv VST: : StatementService:1860 StatementService:getCardReference:0... (3 Replies)
Discussion started by: senthil.ak
3 Replies
Login or Register to Ask a Question