Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect cshell output to both terminal and a file

Status
Not open for further replies.

brandonb

Programmer
May 7, 2002
1
US
Here is my problem. I am writing a perl script which calls a cshell script (using system() ) that(1) expects input from the user and (2) writes to stdout.

I would like to be able to allow the user to interact with the script normally, while also logging output to a file. The typical io redirects don't seem capable of this. Any help would be greatly appreciated.
 
Hi Brandon,

The tee program does what you want. Its name comes from the T junction in plumbing and you use it like this:

[tt]ls -l | tee ls.output[/tt]

From the command line that will put the output of ls -l into a file and display it on the screen.

From a Perl script you would call a csh script like this:

[tt]system('myscript.csh | tee myscript.output');[/tt]

Mike
michael.j.lacey@ntlworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top