LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   output from bash script as an argument?????? (https://www.linuxquestions.org/questions/programming-9/output-from-bash-script-as-an-argument-4175448922/)

rehan21 02-06-2013 01:42 PM

output from bash script as an argument??????
 
Hi Every one,

How to take output from bash script as an argument?

Regards,
Rehan

TB0ne 02-06-2013 01:48 PM

Quote:

Originally Posted by rehan21 (Post 4885746)
Hi Every one,
How to take output from bash script as an argument?

You write your script to read it, that's how. Putting "how to use output from one bash script as input to another" into Google pulls up lots of solutions...have you tried that?
http://stackoverflow.com/questions/1...another-script
http://www.unix.com/shell-programmin...t-another.html

There are different ways to do it, depending on what the first script returns, and how. Also, you need to take into account that STDERR is different than STDOUT, and do you want to capture both, or just one?

drunkenbrawler 02-06-2013 06:50 PM

Yeah, it will depend on what your first script outputs and what the second script wants to do.

In general, you can pipe the output of the first and 'read' it in second script. You can also use 'xargs' (check man page).

bigearsbilly 02-07-2013 03:22 AM

how can I write a bash script to tell me the winner of the 4:30 at Kempton Park?

druuna 02-07-2013 05:07 AM

Quote:

Originally Posted by bigearsbilly (Post 4886077)
how can I write a bash script to tell me the winner of the 4:30 at Kempton Park?

Simple:
Code:

#!/bin/bash

wget -O /tmp/fixed.txt http://match.fixing.cn/.hidden/winners/fixed.matches.txt

grep "Kempton Park" /tmp/fixed.txt | grep "4:30"

:D

rehan21 02-08-2013 11:28 PM

Quote:

Originally Posted by drunkenbrawler (Post 4885901)
Yeah, it will depend on what your first script outputs and what the second script wants to do.

In general, you can pipe the output of the first and 'read' it in second script. You can also use 'xargs' (check man page).

Any example would u like to give ?

Regards,
Rehan

millgates 02-09-2013 04:01 AM

Quote:

Originally Posted by rehan21 (Post 4887438)
Any example would u like to give ?

Regards,
Rehan

Why don't you give us an example of what you are trying to do?

TB0ne 02-09-2013 08:37 AM

Quote:

Originally Posted by rehan21 (Post 4887438)
Any example would u like to give ?

Spell out your words, please. And there are many bash scripting tutorials you can easily find...there is a link to one in my signature here. I gave you links with examples already in my first reply, and there is a sample script in post #5 that druuna provided. How many more examples would you like?

bigearsbilly 02-09-2013 09:10 AM

Quote:

Originally Posted by druuna (Post 4886133)
Simple:
Code:

#!/bin/bash

wget -O /tmp/fixed.txt http://match.fixing.cn/.hidden/winners/fixed.matches.txt

grep "Kempton Park" /tmp/fixed.txt | grep "4:30"

:D


doh!
I shoulda oughta known it!


All times are GMT -5. The time now is 08:13 PM.