The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
let curl output to stdout AND save to a file scarfake Shell Programming and Scripting 3 05-31-2008 04:16 PM
getting stderr & stdout output lively modified teo ramirez Shell Programming and Scripting 2 10-08-2007 01:06 AM
Remote CD woes greg69 SUN Solaris 2 08-15-2007 10:52 AM
Dual output (stdout and file) AdrianM Shell Programming and Scripting 2 03-23-2007 12:35 PM
sending syslog output to stderr or stdout dmirza UNIX for Advanced & Expert Users 1 10-24-2005 06:41 PM

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 07-09-2006
c0nn0r c0nn0r is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 6
Script Output Woes (stdout?)

Hey everyone.

I have been trying a few filtering scripts with both SED and PERL. So far I have both of these versions working to reformat the incoming text stream (from stdin) into the corrent format (it looks good in the terminal), but I don't think that I am doing it right because the formatted text is not available to other applications/operations... but I can see it coming through in the terminal? Is this weird?

this is my setup:

% foo.app | perlFilter.pl

Works great - I can see it in the terminal, but

% foo.app | perlFilter > text

puts nothing into the file text!

% foo.app | perlFilter | nc 127.0.0.1 5001

Shows nothing going through to

nc -l -p 5001

Running nc in verbose mode shows that nothing is going through...

Here is my PERL script:

Code:
#!/usr/bin/perl

while (<>)  {
    $input = $_;
    chomp ($input);
    printf("%s;\n\r", $input);
    }
Do I need to explicitly write out to stdout or something?

I'm a newb.
  #2 (permalink)  
Old 07-09-2006
futurelet futurelet is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 137
Don't use Perl. Use awk, sed, or Ruby.

Code:
% foo.app | append_semicolon.awk >outfile
where the awk file contains
Code:
#!/usr/bin/nawk -f
{ printf "%s;\n", $0 }
or simply do
Code:
% foo.app | nawk '{ printf "%s;\n", $0 }' >outfile
Using Ruby:
Code:
% foo.app | ruby -lne 'print $_,";"' >outfile
  #3 (permalink)  
Old 07-09-2006
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,209
Please do not start any more threads for this topic, use one of your existing ones.
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 05:46 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