The UNIX Forums  



Go Back   The UNIX Forums > Top Forums > Shell Programming and Scripting
Home Forums Register Rules & FAQDonate Members List Search Today's Posts Mark Forums Read

Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
Submit Tools Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-22-2004
Registered User
 
Join Date: Oct 2001
Location: Bangalore
Posts: 93
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Printing output to the monitor

Hi!,

In my shell scripts, I always create a logfile by adding the following line in the beginning:

exec >file.log 2>&1

This in turn directs all the output to this logfile till the script executes.

But now, I have to write some output to the monitor for the users.

So, i am doing it by the following method:
========================
CUR_DEVICE=`tty`
echo "Whatever to be outputed" >$CUR_DEVICE
========================

This works for me.. But is there any better way than this??
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-22-2004
Ygor's Avatar
Moderator
 
Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,181
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
You can write to the current terminal using /dev/tty

e.g: echo "message" >/dev/tty

You could even open a new file descriptor.

e.g: in ksh:

exec >file.log 2>&1 3>/dev/tty
:
print -u3 "message"
Reply With Quote
Forum Sponsor
  #3 (permalink)  
Old 06-22-2004
Registered User
 
Join Date: Oct 2001
Location: Bangalore
Posts: 93
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
:)

Thanks.. That works great....
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
printing output more than 13 Krrishv Shell Programming and Scripting 2 01-22-2007 03:35 AM
Printing to a Savin - Size of output wrong h1timmboy AIX 2 02-28-2006 07:19 AM
How to monitor pty l-roner AIX 2 07-08-2005 09:17 AM
PC monitor mangolinux SUN Solaris 1 02-14-2005 02:58 PM
Printing Problems in unix ... ( Bar-cdoe - Ip Printing) QuickSilver UNIX for Advanced & Expert Users 3 06-04-2002 09:48 AM


web tracker

All times are GMT -5. The time now is 03:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
UNIX Forum Content Copyright ©1993-2008 SilkRoad Asia All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93