Solved

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

Posted on 2012-03-21
8
749 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
 
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Plain Text Editor for iPad 6 60
iSeries email authority 4 25
SQL query question 8 39
reset ubuntu password for root and admin after clearing it. 7 24
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
This is about my first experience with programming Arduino.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

920 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

15 Experts available now in Live!

Get 1:1 Help Now