Solved

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

Posted on 2012-03-21
8
761 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)
ID: 37750379
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
ID: 37751983
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)
ID: 37752127
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:DRSLT
ID: 37752314
$.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
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37752356
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
ID: 37752403
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
ID: 37752422
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
ID: 37752593
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
blank screen when trying to setup Unity on Ubuntu 14.04 9 41
oracle numeric condition check 4 27
oracle collections 2 19
oracle sqlplus query delimiter 8 16
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

791 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