Solved

Output redirection

Posted on 1999-01-19
8
330 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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…
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.

809 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