1

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?

  • Is the output you want appears on the screen ? – Razique Feb 4 '10 at 10:07
1

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
  • yes, perfectly! actually I should have done program2 $(program1) – phunehehe Feb 4 '10 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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