Solved

Output redirection

Posted on 1999-01-19
8
333 Views
Last Modified: 2010-04-21
I have the following execution:

 /safari/udms/udmsshr -BATCH-EXIT RPW PRSPAY SELECT REPORT3 GENERATE  < /usr/mhas
hmi/U2096.INP.

I want to be able to redirect the resulting report to another file, and then print using the lp command to my default printer.
Any help appreciated
0
Comment
Question by:jamus
8 Comments
 
LVL 3

Expert Comment

by:mliberi
ID: 2009302
you can redirect output of your command by adding >filename to your command. If it doesn't work (your command doesn't write output to stdout) you can try with 2>filename.

You can also print the output without creating a temporary file by piping your command to lp
command ¦ lp
0
 

Expert Comment

by:adum
ID: 2009303
You might want to use the 'tee' command, so, you'll have something like:

foo < bar | tee logfile | lpr

That sends it to a file as well as the printer.

adum
0
 

Author Comment

by:jamus
ID: 2009304
This doesnt seem to work:
' | lp ' message reads 'standard input is empty'.
' > filename' produces an empty file
 as the current script stands it automatically outputs to the screen (I believe this is due to the executable file 'udmsshr')
Thanks
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 84

Expert Comment

by:ozo
ID: 2009305
if it's outputing to stderr, you could redirect it with
2> file
or
>& file
depending on which shell you're using
0
 
LVL 3

Expert Comment

by:mliberi
ID: 2009306
Did you try "2>filename" ?

If this doesn't work probably the executable contains an explicit "freopen" or "fopen" with /dev/tty.
Search the executable with the "strings" command, if it output, among other stuff, the "/dev/tty" string do the following:
1. make a backup copy of your executable
2. change with a binary editor the string "/dev/tty" with "xxxxxxxx"
3. restart your program
4. your output should be redirected to "xxxxxxxx"

I assumed you don't own the source, but if it is not true the best way to do the job is locating the "/dev/tty" string in the source, change it, and recompile.
0
 

Author Comment

by:jamus
ID: 2009307
thanks Mliberi
0
 
LVL 3

Expert Comment

by:mliberi
ID: 2009308
Why did you reject?
0
 
LVL 3

Accepted Solution

by:
mliberi earned 100 total points
ID: 2009309
submitting the same answer, probably you hit wrong button.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

713 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