Professional Web Applications Themes

shell question - FreeBSD

Hello FreeBSD gurus! I address you in hope of enlightment. Here is the problem: I have a program that creates a PostScript output and writes it to its standard output. This program also writes diagnostic messages to the standard error output at the same time, in this case the messages are written in plain text. I need to concatenate the standard output and then standard error output in a file, but I need to convert the standard output into PostScript before the concatenation. program <stdin >stdout 2> stderr cat stdout > out a2ps stdout >> out a2ps is in the ...

  1. #1

    Default shell question


    Hello FreeBSD gurus!

    I address you in hope of enlightment.

    Here is the problem:

    I have a program that creates a PostScript output
    and writes it to its standard output.

    This program also writes diagnostic messages to
    the standard error output at the same time, in
    this case the messages are written in plain text.

    I need to concatenate the standard output and
    then standard error output in a file, but I need
    to convert the standard output into PostScript
    before the concatenation.

    program <stdin >stdout 2> stderr
    cat stdout > out
    a2ps stdout >> out

    a2ps is in the ports and it converts plain text
    into PostScript.

    The problem is that I don't want to use the temporary
    file that I used above (stdout, stderr, out), I just
    want a "filter"

    In a diagram, it can be seen as:

    stdin ==> program ==> [stdout, a2ps(stderr)]


    I have tried:

    cat stdin | program 2> tmp | ( cat && a2ps tmp )

    but I still need a temporary file.

    Can it be done?
    Can you help me and tell me how ?

    Thanks in advance.

    -Eduardo.

    PS. Please, answer to my e-mail address, I am not
    subscribed to the list.


    mrspock@esfm.ipn.mx Guest

  2. #2

    Default RE: shell question

    mrspock at esfm dot ipn dot mx wrote:
     
    standard 
     
    PostScript. 
     
    "filter"

    program < stdin 3>&1 1>&2 2>&3 | a2ps

    Regards Björn

    Björn Guest

  3. #3

    Default RE: shell question

     [/ref]

    You meant

    program <stdin >stdout 2> stderr
    cat stdout > out
    a2ps **stderr** >> out

    Don't you?

    Björn Guest

  4. #4

    Default RE: shell question

    On Tue, 5 Apr 2005, Björn König wrote:
     [/ref]
    >
    > You meant
    >
    > program <stdin >stdout 2> stderr
    > cat stdout > out
    > a2ps **stderr** >> out
    >
    > Don't you?
    >[/ref]
    yes! sorry!

    Eduardo Guest

  5. #5

    Default Re: shell question

    In article <135.130.41>, mrspock (m) writes:

    m> The problem is that I don't want to use the temporary
    m> file that I used above (stdout, stderr, out), I just
    m> want a "filter"

    If you want to rearange the output so that all the errors are after
    all the non errors, then you are going to need storage of some sort. I
    think that is logically unavoidable.

    There may be some kind of shuffle you can do with named pipes or
    something, but those kind of things have limited storage. Any time
    your command produces more error output than that space can hold, it
    will be stopped. Since you are not reading that stream until the main
    output is finished you'd then have a deadlock.

    --
    Mail me as org.uk _O_
    |<

    Richard Guest

  6. #6

    Default RE: shell question

    On Tue, 5 Apr 2005, Björn König wrote:
     
    > standard 

    > PostScript. 

    > "filter"
    >
    > program < stdin 3>&1 1>&2 2>&3 | a2ps
    >
    > Regards Björn
    >[/ref]

    Thanks for your help, Björn.

    I think I'd better study a little more this redirection operators.

    Thanks again.

    Eduardo.
    Eduardo Guest

  7. #7

    Default Re: shell question

    On Wed, 6 Apr 2005, Richard Caley wrote:
     

    Thank you, Richard.

    Efectively, I found that is easier to create a temporary file with
    one of the output files, in this case "stderr". Stderr is used,
    in this case to create a listing of the data that the program is
    using and, occasionally, it issues an error message, in this case
    the program stops.

    I finally programmed this process in this way:

    program 2> tempfile | (cat && a2sp tempfile) | ps2pdf

    As I already stated, my program is creating a PostScript output
    in its stdout and a "listing" in the stderr file. a2ps is
    converting this listing to PostScript and both of them, finally,
    are converted to a PDF doent with GhostScripts [in the ports].

    Finally, the name "pipes" is very precise to describe what is
    happening with the "streams"; obviously, if I want to process one
    of the streams after the other one, I need to contain the "water"
    of the second temporally.

    Thanks for your time and your help.

    Eduardo.


    PS.
    Perhaps you are interested in visiting my page:

    http://michelle.esfm.ipn.mx/~mrspock/superspiro

    Cut & Paste one of the examples and execute the program at the
    end of the page.



    Eduardo Guest

Similar Threads

  1. Shell script question
    By Digish Reshamwala in forum FreeBSD
    Replies: 5
    Last Post: February 18th, 04:20 AM
  2. SHELL QUESTION
    By Ken in forum AIX
    Replies: 4
    Last Post: October 14th, 11:42 PM
  3. Shell question.
    By Samir Sethi in forum PHP Development
    Replies: 0
    Last Post: September 10th, 05:07 PM
  4. Shell Question..
    By Rus Foster in forum Debian
    Replies: 4
    Last Post: July 21st, 08:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139