468,733 Members | 2,083 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,733 developers. It's quick & easy.

using perl to override output redirection

2
Hi,

Could anyone point how can i override output redirection using perl.
i.e.
command > file 2>&1 will redirect both output and error of command to file
I need to print a message to tty even if there is redirection.
Oct 17 '07 #1
2 2974
numberwhun
3,503 Expert Mod 2GB
Hi,

Could anyone point how can i override output redirection using perl.
i.e.
command > file 2>&1 will redirect both output and error of command to file
I need to print a message to tty even if there is redirection.
Well, one way is to use the open() function and open the file / connection. Then, use a print statement to print to the filehandle from the open function.

ie:
Expand|Select|Wrap|Line Numbers
  1. open(TTY, "|<tty connection>");
  2.  
  3. print TTY ("Your info here!\n");
  4.  
Hope that helped.

Regards,

Jeff
Oct 17 '07 #2
prajil
2
Well, one way is to use the open() function and open the file / connection. Then, use a print statement to print to the filehandle from the open function.

ie:
Expand|Select|Wrap|Line Numbers
  1. open(TTY, "|<tty connection>");
  2.  
  3. print TTY ("Your info here!\n");
  4.  
Hope that helped.

Regards,

Jeff

Hi Jeff,

Thanks for your reply. But still it is redirecting to the output file.
------------
>./eg.pl
not a tty
>
-----------
>./eg.pl >& file
>
-------------
Oct 18 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Mark Wilson CPU | last post: by
3 posts views Thread by msnews.microsoft.com | last post: by
reply views Thread by Tom Gaudasinski | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.