Solved

Oracle Printer Driver saves to folder location -- need to rename extension too

Posted on 2012-03-21
8
743 Views
Last Modified: 2012-03-22
I currently have a printer driver set up in Oracle R12 that saves the output to a directory rather than sending to a pring using the following as the argument

mv $PROFILES$.FILENAME /var/tmp/Oracle_Reports/XXC3_RESP_AUD_RPT/

This works fine.  However, the file is an Excel file with an extension of .EXCEL rather than .XLS or .xls.  I would like to use the above command to also rename the extension, but have not been successful as of yet.
0
Comment
Question by:DRSLT
  • 4
  • 4
8 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
My unix is rusty but you should be able to use sed to change the extension.

Try the code below, I got the original from:
http://lab.artlung.com/unix-batch-file-rename/


mv $PROFILES$.FILENAME var/tmp/Oracle_Reports/XXC3_RESP_AUD_RPT/`echo $PROFILES$.FILENAME | sed 's/\(.*\.\)EXCEL/\1XLS/'`
0
 
LVL 1

Author Comment

by:DRSLT
Comment Utility
slightwv

Thanks for the update.  This renames the file with the new extension, but it also includes the original UNIX path of the file as part of the filename.  $PROFILES$.FILENAME is the original path + filename, so your code tries to rename it to the following

/var/tmp/Oracle_Reports/XXC3_RESP_AUD_RPT/<ORIGINAL UNIX PATH>+<BASE FILENAME>.xls

which throws an error since that path doesn't exist.  I need to pull the filename from $PROFILES$.FILENAME and the solution would work.

Any ideas???
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
Wouldn't it just be the $.FILENAME?  try just removing $PROFILES:

mv $PROFILES$.FILENAME /var/tmp/Oracle_Reports/XXC3_RESP_AUD_RPT/`echo $.FILENAME | sed 's/\(.*\.\)EXCEL/\1XLS/'`
0
 
LVL 1

Author Comment

by:DRSLT
Comment Utility
$.FILENAME is a litteral without $PROFILES preceding it.  I was hoping to use basename to get rid of the UNIX folder, but that does not seem to be working.

Thanks for the advice so far.  Still looking for the solution.  Any additional suggestions appreciated.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
I guess I'm not understanding what $PROFILES$.FILENAME is and where it comes from.

So .FILENAME is what produces .EXCEL?

Can this be 2 steps?

First the mv above then maybe something like (remember my unix is from memory):
mv /var/tmp/Oracle_Reports/XXC3_RESP_AUD_RPT/*.EXCEL *.XLS
0
 
LVL 1

Author Comment

by:DRSLT
Comment Utility
It is a parameter in a the UNIX print command from Oracle.  It is the name of the file being output to the printer.  It is in a UNIX directory and we are using the mv command to move it to a windows system directory (which works great).  The problem is renaming the extension.

The argument $PROFILES$.FILENAME is the <UNIX path>  + <FILE> being passed to the printer.  In this case the printer driver is set up to move the file to the windows system directory by specifying the mv command in the argument for the printer driver.

==================================================================================

Passing Arguments to UNIX lp Print Command

 Argument Syntax  Token and Value Retrieved  
 
-d$PROFILES$.PRINTER -d calls out the destination printer.  $PROFILES$.PRINTER retrieves the operating system name of the printer associated with the request.  
 
-n$PROFILES$.CONC_COPIES -n calls out the number of copies to print.  $PROFILES$.CONC_COPIES retrieves the value of the profile option Concurrent:Report Copies, unless this value is updated at runtime.  
 
-t"$PROFILES$.TITLE" -t calls out the report title to print on a banner or header page.  "$PROFILES$.TITLE" retrieves the title of the output file, typically titled as Application username.Request ID. For example, if user John Smith ran a report whose concurrent request ID was 64225, the title would be JSMITH.64225. This is operating system dependent.  
 
$PROFILES$.FILENAME  $PROFILES$.FILENAME calls out the filename of the report to be printed. The value retrieved is the output file name, including the path to the file.  

(from http://docs.oracle.com/cd/A60725_05/html/comnls/us/fnd/custom01.htm)
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
Comment Utility
Thanks for that.  It helped a lot.

See if basename is on your system:
http://www.unix.com/unix-dummies-questions-answers/42159-remove-path-filename.html

mv $PROFILES$.FILENAME /var/tmp/Oracle_Reports/XXC3_RESP_AUD_RPT/`basename $PROFILES$.FILENAME | sed 's/\(.*\.\)EXCEL/\1XLS/'`
0
 
LVL 1

Author Closing Comment

by:DRSLT
Comment Utility
Thanks for your help.  As I indicated previously, I wanted to use basename, but I must not have been getting the syntax right.  Your last post did it!

Thanks a lot!  Points coming your way.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now