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 [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to