Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Output redirection

Posted on 1999-01-19
8
Medium Priority
?
338 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 200 total points
ID: 2009309
submitting the same answer, probably you hit wrong button.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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…
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…
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.

610 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