The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to use tee with stdout and stderr? siegfried Shell Programming and Scripting 3 01-14-2009 10:07 PM
precedence of stderr and stdout new2ss Shell Programming and Scripting 1 06-09-2006 12:03 AM
sending syslog output to stderr or stdout dmirza UNIX for Advanced & Expert Users 1 10-24-2005 07:41 PM
STDOUT and STDERR going to a system log longyie904 Shell Programming and Scripting 1 09-12-2002 12:42 AM
Redirect stdout and stderr zcurtis Shell Programming and Scripting 8 09-02-2002 07:13 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-08-2007
teo ramirez teo ramirez is offline
Registered User
  
 

Join Date: Oct 2007
Location: spain
Posts: 4
getting stderr & stdout output lively modified

This is about getting all output to stderr and stdout localized. Nothing to do with redirecting output to a file (there already are some interesting threads about that issue on this forum).

What I intend to do is capturing all lines of text sent to the screen, compare them with an array of stored lines and replace the matching ones in the screen for their translated equivalents.

I'm aware of TEXTDOMAIN and alike, but unfortunately many scripts are not prepared for localization, so I want to try a different approach, tryng to translate everything carelessly if the script uses $"" or not for calling gettext.

I have been trying 2 ways:

1: Getting many commands that generate writen output intercepted. After editing etc/profile, ~/bashrc, setting aliases, expand_aliases and lots of things, I can get them catched only in interactive mode, but when running a script, no alias at all is keept (nor other settings). F.i., if I type "enable" in the shell, I see that echo has dissapeared (I replace it for my own). But running a script that contents the same command, echo is enabled again!. Should not expand_aliases have avoided this?

2: Some kind of daemon that could replace the standard output and give back the translated messages (or the original ones if not matched). Even it could be enough to append the translated lines to the already shown in english. I guess that I would have to redirect /dev/fd/? , /dev/tty? or something like that but i lack the knowledge to do it, if it can be done. Some tries done with no succes.

Could anybody point a solution, advise, whatever could help?

Thank you in advance.

T. Ramírez
Ferrol (Spain)
  #2 (permalink)  
Old 10-08-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,126
You would need to use C or something like that. This is beyond what I want want to try via a script. perl could handle it though. basicly you will need to allocate a psuedo tty and arrange for the user to interact with the pty. Your program would sit between the user's "real" tty and the psuedo tty you allocate. The program called "script" does all of this, not to translate, but to capture all input and output to a file. So you could obtain the source code to script and study that as a starting point.
  #3 (permalink)  
Old 10-08-2007
teo ramirez teo ramirez is offline
Registered User
  
 

Join Date: Oct 2007
Location: spain
Posts: 4
Quote:
Originally Posted by Perderabo View Post
You would need to use C or something like that. This is beyond what I want want to try via a script. perl could handle it though. basicly you will need to allocate a psuedo tty and arrange for the user to interact with the pty. Your program would sit between the user's "real" tty and the psuedo tty you allocate. The program called "script" does all of this, not to translate, but to capture all input and output to a file. So you could obtain the source code to script and study that as a starting point.
I thank you very much your response. Those are bad news, since I have never learned either C or Perl. I'm not sure how but I'll try with Pascal.

Well, that can stand for "way #2". Perhaps I'm not well aware about what can be done with shell scripting and what not. But.. what about the first method? do you/anybody know why aliases don't work when running scripts, in spite of having set shopt -s expand_aliases?. Surely I'm doing something wrong. If not, what is that option supossed to be intended for?

Best,

T. Ramírez
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

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




All times are GMT -4. The time now is 12:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0