Solved

Output redirection

Posted on 1999-01-19
8
326 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
 
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
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 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

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!

Join & Write a Comment

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

747 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