RE: Send output to file & printer

From: Ben Yau (byau_at_cardcommerce.com)
Date: 01/30/04

  • Next message: dokumenty_gdansk_at_zus.pl: "Odpowiedz z ZUS"
    To: "debian users" <debian-user@lists.debian.org>
    Date: Fri, 30 Jan 2004 14:41:21 -0800
    
    

    Jim says:
    >
    > As an example, if I issue a command like "ls -laF" on a directory, can I
    > have the output of that command go to a file (filename =
    > username_date_time.txt), and print on a remote printer at the
    > same time, or
    > do I have to run two commands?
    >

    There are a lot of strange ways to get this one done. The easiest way is to
    do it in two commands. However, you can put both commands on the same
    command line though

    prompt# [first command] > output.txt; [print command] output.txt

    If you want a wrapper script, try this one. Be warned there are not a lot
    of sanity checks in this so use at your own risk (and test the syntax also).
    Let's say you save hte script to "printarchive". Then usage would be
    somehting lke

    prompt# printarchive ls -laF

    here's the script

    #!/bin/bash
    #

    # what's our print command?

    prtcmd="lpr -Php4050"

    # where do we store the outputted flies?
    outputdir="/tmp"

    # define our output file as "printjob.datetime.processid.txt"

    datesuffix=`date +"%Y%m%d_%H%M%S"`
    pidstuffix=$$

    # let user know where the outputfile to STDOUT
    outfile="$outputdir/printjob_$datesuffix.$$.txt"
    echo "OUTPUT to $outfile"

    # run command and save to file
    $* > $outfile

    # output file to screen first and then confirm we wnat to print it
    cat $outfile

    # confirm print
    echo ""
    echo -n "Hit <ENTER> to print, ctrl-c to interrupt and cancel"
    read userinput

    # now print the file
    $prtcmd $outfile

    # done
    echo "done, output printing via $prtcmd $outfile"

    -- 
    To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: dokumenty_gdansk_at_zus.pl: "Odpowiedz z ZUS"

    Relevant Pages

    • Re: Ahve got them Function Pointer blues
      ... struct FS ... My problem is that the <function pointer> is of unknown type - in ... and producing an output file. ... The commands will be, for example ...
      (comp.lang.c)
    • Re: Ahve got them Function Pointer blues
      ... and producing an output file. ... The commands will be, for example ... forth-like stack, with each stack element being a ... structure, which contains, among other things, a pointer to the function ...
      (comp.lang.c)
    • Re: Clone iMacs?
      ... and in unix, everything is a file. ... On 3/28/07, David Stubblebine wrote: ... I am just not sure about the commands. ...
      (Ubuntu)
    • Re: Using ShellExecute
      ... program contains filenames for the input (a set of commands) and the output ... I want to process the output file. ... is there some way of checking if the batch program is finished so I ...
      (borland.public.delphi.non-technical)
    • Re: Persisting env vars in cmd windows
      ... You're doing very nicely with your batch file commands. ... Call CreatePathAndSymbols.bat _Pf Prmp ... @echo off ... the separate batch files that can be invoked stand-alone, ...
      (microsoft.public.win2000.general)