Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to create script to send file to a printer

Status
Not open for further replies.

Evette

Programmer
May 10, 2002
9
US
I need to send the results of a file that is created every Sunday and Wed to a printer. Can this be setup as a cron Job?

The report would be sent to the printer at 5am on Monday and Thursday every week.

Help.
 
man crontab:

minute (0-59),
hour (0-23),
day of the month (1-31),
month of the year (1-12),
day of the week (0-6 with 0=Sunday).

your entry (untested) would look like this:

0 5 * * 0,3 yourprogramorscript

Regards,

Ed
 
Hi Evette,

here is a small Korn Shell Script that does the trick:

#! /bin/ksh

EMAIL=evette@something.com

FILE2SEND=absolute_path_of_your_file_name

cat $FILE2SEND | mailx -s "here is your file" $EMAIL

exit 0

Make the script file executable and put it in your crontab:

0 5 * * 1,4 absolute_path_of_your_script > /dev/null 2>&1

mrjazz [pc2]
 
Sorry, it's been a long day... [sleeping2]

My above script does not send the file to a printer, it sends a mail to a user.

Just replace the mailx command with an lp command.

mrjazz
 
Thanks for the info. Another How can I get the most recent file to print the file is found in this directory

ADAC2/ars11/infostat> cd /infostat/bin/dba/tools/sizing
ADAC2/ars11/infostat/bin/dba/tools/sizing> ll
total 388
-rw-r--r-- 1 oracle dba 18169 Jun 30 01:00 ckspc.out.020630.01:00
-rw-r--r-- 1 oracle dba 18169 Jul 3 01:00 ckspc.out.020703.01:00
-rw-r--r-- 1 oracle dba 18169 Jul 7 01:00 ckspc.out.020707.01:00
-rw-r--r-- 1 oracle dba 18818 Jul 10 01:00 ckspc.out.020710.01:00
-rw-r--r-- 1 oracle dba 18980 Jul 14 01:00 ckspc.out.020714.01:00
-rw-r--r-- 1 oracle dba 18980 Jul 17 01:00 ckspc.out.020717.01:00
-rw-r--r-- 1 oracle dba 19304 Jul 21 01:00 ckspc.out.020721.01:00
-rw-r--r-- 1 oracle dba 18655 Jul 24 01:00 ckspc.out.020724.01:00
-rw-r--r-- 1 oracle dba 16468 Jul 28 01:00 ckspc.out.020728.01:00
-rw-r--r-- 1 oracle dba 16468 Jul 31 01:00 ckspc.out.020731.01:00
-rwxr-xr-x 1 oracle dba 1017 Jan 9 2001 ckspc.sh
-rwxr-xr-x 1 oracle dba 5463 Jan 9 2001 ckspc.sql
-rwxr-xr-x 1 oracle dba 861 Jan 9 2001 data_file.sql
-rwxr-xr-x 1 oracle dba 1520 Jan 9 2001 free_ts.sql
-rwxr-xr-x 1 oracle dba 643 Jan 9 2001 prep_free_ts.sql

How can get the most recent file to be printed to a specific printer.

Thanks.
 
Mr Jazz, it's been a long day for me to. My eye saw Sunday and Wednesday - Sorry!
As far as finding the last data file, I think this might do it:


#!/bin/ksh

ll > d.file

# strip out just the datafiles and find the largest of
# field 9
lastfile=`grep ckspc.out d.file|awk '
{
if($9 > lf)
lf=$9
} END { printf("%s\n", lf) } '`

echo $lastfile
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top