Linux command--tee redirect to file and print to screen

Source: Internet
Author: User

Demand:

It comes from a business implementation that requires a shell script to tune the Java program, and the ability to get the return value inside java.

Ideas:

As is known to call Java through the shell, it is definitely through the Java-jar Xxx.jar command to call a jar of a main function, if you want to return the value, the best way is certainly System.out.println ("return value"), Can be analogous to how the log is printed. Or you can use echo $ to get the value returned to the OS. Since the way to log, then of course, through the > method into a log file, how to store to log files and can be displayed on the screen?

There's a tee command in Linux,

Function Description: Reads the standard input data and outputs its contents to a file. Language  method: Tee [-ai][--help][--version][file ...] Supplemental NOTE: The tee instruction reads data from a standard input device, outputs its contents to a standard output device, and saves it as a file (a new file is created when the file does not exist). Parameter  :-A or--append  attached to the back of the existing file rather than overwriting it. The  interrupt signal is ignored by the-i-i or--ignore-interrupts  .  --help  online Help.  --version  Displays version information.

Detailed. SH is as follows:

#sh./install.shclaspath= '. /lib/*:.. /plugins/* '. /jre/bin/java-dbsp-mysql-dlogback.configurationfile=. /conf/logback.xml-dbase.dir=. /-CP $claspath Com.broada.bsp.mysql.TestAvgs |tee run.log 2 &

  

Linux command--tee redirect to file and print to screen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.