Stefan Gremm wrote:
> Hello,
> 
> first excuse me my bad english.
> 
> i have write a little send_mail script. now i pipe the messagetext from
> another program, like cat /var/mailtext| send-mail.rb
> 
> the program source:
> 
> smtp_message = ""
> 
>  temp = $stdin
> 
>  temp.each do |f|
>     smtp_message += f
>  end
> 
> this is runing very well, but when no text is in the pipe, the program
> is waiting for input.
> 
> my question is, how can i ask, if text in $stdin, without the program is
> waitung for input.
> 
> ciao
> 
> Stefan


Try the -n option
  > -n              assume 'while gets(); ... end' loop around your 
script


#code
smtp_message = ""
$_.each do |f|
    smtp_message += f
end
#endcode


cat /var/mailtext| ruby -n send-mail.rb

-rb


-- 
Posted via http://www.ruby-forum.com/.