Re: redirecting stdout in script

From: Frank Chiavoni (Frank.Chiavoni_at_OIT.STATE.NJ.US)
Date: 08/03/05

  • Next message: Frank Chiavoni: "Re: redirecting stdout in script"
    Date:         Wed, 3 Aug 2005 10:33:31 -0400
    To: aix-l@Princeton.EDU
    
    

    Shawn Bierman wrote:
    > I would like to redirect the output of a command in my script to the the input of a function in the same script. Is this possible?
    >
    >
    > example:
    >
    > *- snip *-
    > #!/bin/ksh
    >
    > myprint () {
    > print "myoutput: $*"
    > }
    >
    > ls file* | myprint
    > *- snip *-
    >
    > Any ideas on how to execute this or suggestions on a better way?
    >
    > I want to control the output of the command so I can format it like this:
    >
    > myoutput: file1
    > myoutput: file2
    > myoutput: file3
    > ...
    >
    > thanks.
    > -shawn

    Maybe...

    #!/bin/ksh

    myprint () {
          eval "$x" |
          while read y
          do
             print "myoutput: $y"
          done
    }

    x='ls mdisk*'
    myprint

    Frank


  • Next message: Frank Chiavoni: "Re: redirecting stdout in script"

    Relevant Pages