redirecting script output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers redirecting script output
# 1  
Old 10-02-2011
redirecting script output

Hello,

I am interested in taking the output from a script i wrote and using it as input to a different script i wrote. So for example i want to take the output from program2 and use it as a parameter for program1. I didnt think i could use the >> symbols because i think that is just for .txt files. And i thought about piping the code from program1 into program2. However i dont really know how the syntax would look for a solution like this. So does anyone have a suggestion? Thanks.
# 2  
Old 10-02-2011
it depends on your need, write an example that covers everything, then we can help you,

the simplest thing is to :
Code:
./script1 > output
./script2 `cat output`

you can get all args by $@ in your script2 code.
# 3  
Old 10-02-2011
ok so this program greps the file $p for the parameter that the user enters and outputs some modified text with sed.

grep $1 $p|sed s/.*=.//|sed 's/<.*//'


this program greps the parameters the user enters in the file $q and cuts out a certain column that i want

grep "$*" $q|cut -c77-78


now what i want to do is take the output from the second program and use it as the parameter in program 1. Make sense?
# 4  
Old 10-02-2011
so if the command1 is :
Code:
 grep $1 $p|sed s/.*=.//|sed 's/<.*//'

and command2 is :
Code:
 grep "$*" $q|cut -c77-78

and you want to grep the command1's result in command2:
Code:
 grep "`grep $1 $p|sed s/.*=.//|sed 's/<.*//'`" $q|cut -c77-78

so you can merge them into one command.
This User Gave Thanks to ieth0 For This Post:
# 5  
Old 10-02-2011
i want to use command2 result in command 1. so the part in double quotes would be command 2

---------- Post updated at 06:20 PM ---------- Previous update was at 06:05 PM ----------

ok i got it thank you
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirecting the output

For example, if we run the below command, symcfg list -thin -pool , results in an output most of the times and if the out is generated i'm able to redirect the output to a file. but sometimes it doesnt result any output and even though the output is being redirected, i can see "No Thin Pools "... (2 Replies)
Discussion started by: web2moha
2 Replies

2. Shell Programming and Scripting

Redirecting command output to a file in a shell script

Hello All, I have some unique requirement. I have written a very lengthy script which calls number of resource script to execute a particular task. What I want is output of each command(called from main script and resource scripts) should go to a... (3 Replies)
Discussion started by: anand.shah
3 Replies

3. Shell Programming and Scripting

Redirecting output for the entire script

Hi All, I am trying to redirect output for every line in a korn shell script that is going to generate output and append it to a log file. I have been doing this after EACH and every line that is going to produce output: command 1 >> test.log command 2 >> test.log command 3 >>... (5 Replies)
Discussion started by: MIA651
5 Replies

4. Shell Programming and Scripting

Redirecting script output to terminal

When ever i started my terminal,Every time I have to change the directory like "cd user/documents/ravi/folder2/folder3" Without typing this entire command every time ,I placed "alias c='cd user/documents/ravi/folder2/folder3'" in .bash_profile file. so that i can able to execute command 'c'... (6 Replies)
Discussion started by: Raviteja saddal
6 Replies

5. Shell Programming and Scripting

redirecting output using if-then-else in awk

I am trying to filter records based on number of "|", delimiter in my application. If number of "|" is greater than 14 its a bad record, else its a good record. I have to redirect output to two different files based on the if-then-else evaluation in AWK. if number of “|” in file_0 > 14 ... (2 Replies)
Discussion started by: siteregsam
2 Replies

6. UNIX for Dummies Questions & Answers

redirecting the script output to more than 1 file

Hi, I want to redirect my script output to more than one file without printing the result to the screen. How to do that? ex: echo "hi" >> a.txt b.txt cat a.txt hi b.txt :confused: (2 Replies)
Discussion started by: boopathyvasagam
2 Replies

7. Shell Programming and Scripting

help redirecting output from mailbot

Hello...I'm having problems redirecting output from a script from a mailbot. It is a perl script that has the email sent to op_shipper piped into it. I am receiving the email with sendmail and here is what my alias looks like for the script am I having problems with in /etc/aliases: ... (3 Replies)
Discussion started by: kuliksco
3 Replies

8. Shell Programming and Scripting

redirecting SQL output from within a shell script

Hi all I would like to open a SQL session from within a shell script and then redirect the output of the SQL command to a file. e.g. #!/bin/bash sqlplus "/ as sysdba" <<EOF @$HOME/recovery_space.sql EOF I want to redirect the output of the SQL command to a temp file, because... (2 Replies)
Discussion started by: soliberus
2 Replies

9. Shell Programming and Scripting

Redirecting OUTPUT

Hi, I want to move the output of a command/script to a file as well as to to be displayed on stdout. Can anybody help me in this. Thanks in advace .. -Chanakya M (1 Reply)
Discussion started by: Chanakya.m
1 Replies

10. Shell Programming and Scripting

Redirecting to standard output from within called script

Hi, How to achieve this? Let us assume the following: There are 2 scripts a.ksh and b.ksh $ cat a.ksh sh b.sh 2>&1 >> /work/log/a_log.txt $ cat b.sh echo "abcd" My requirement is, is there a way to display this abcd in standard output also alongside of writing into a_log.txt?... (8 Replies)
Discussion started by: vigneshra
8 Replies
Login or Register to Ask a Question