Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm new to shell-scripting and I guess this should be something quite easy. Anyway I don't know how to force redirect a program's output to the input of another program. I know about the pipe, where you can do

program1 | program2

But in my case, I guess the output of program1 is already redirected somewhere else (this is a long script that someone else wrote). When I tried on a separate command prompt, the result is as expected, but when I put it inside the script program2 gets upset about missing parameters. Can I somehow force it?

share|improve this question
    
Is the output you want appears on the screen ? –  Razique Feb 4 '10 at 10:07
add comment

1 Answer

up vote 1 down vote accepted

i'm afraid there is no easy answer to this. first of all you have to find where program1 is redirecting its output to. to give you some hints what to search for, take a look at this.

when you've found out, let program1 print to stdout. this way the output of program1 will get piped to the input of program2.

as you say "gets upset about missing parameters" it could also be, that program2 is not able to read all information from stdin. when you use the output of program1 as parameters to program2, try xargs:

program1 | xargs program2
share|improve this answer
    
yes, perfectly! actually I should have done program2 $(program1) –  phunehehe Feb 4 '10 at 16:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.