Solved

Output redirection

Posted on 1999-01-19
8
334 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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

Technology Partners: 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!

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…
Suggested Courses

734 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