Re: [Boston.pm] Fwd: script works ok on command line, hangs when run from shell script

Andrew Feren <[email protected]>
Newsgroups gmane.comp.lang.perl.perl-mongers.boston
Message-ID <[email protected]>
I'd definitely start by not using csh. It has a pile of problems as a scripting language. Especially related to pipes and file descriptors. 

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

-Andrew

> On Apr 27, 2017, at 11:18, Bill Ricker <[email protected]> wrote:
> 
> Apparently i replied off-list.  Here's my reply for those following along
> at home.
> 
> // Bill
> 
> ---------- Forwarded message ----------
> 
> 
> Is your interactive commandline provided by (ba)sh or [tcz]sh ?
> I see your script is Csh.
> That's one possible difference since that's where the pipe is actually
> created and sub-process spawned.
> 
> $| won't
> ​do what you want.
> 
> perldoc -v '$|'
> 
> HANDLE->autoflush( EXPR )
> $OUTPUT_AUTOFLUSH
> $|
> 
> If set to nonzero, forces a flush right away and after every write or print
> on the currently selected output channel. Default is 0 (regardless of
> whether the channel is really buffered by the system or not; $| tells you
> only whether you've asked Perl explicitly to flush after each write).
> STDOUT will typically be line buffered if output is to the terminal and
> block buffered otherwise. Setting this variable is useful primarily when
> you are outputting to a pipe or socket, such as when you are running a Perl
> program under rsh and want to see the output as it's happening. This has no
> effect on input buffering. See getc for that. See select on how to select
> the output channel. See also IO::Handle.
> 
> Mnemonic: when you want your pipes to be piping hot.
> 
> ​ If you want actual non-blocking output in an output pipe or to a file, I
> _think_ you'll need
> ​
> perldoc IO::Handle
> 
> ​*$io->blocking ( [ BOOL ] )*
> 
> If called with an argument blocking will turn on non-blocking IO if BOOL is
> false, and turn it off if BOOL is true.
> 
> blocking will return the value of the previous setting, or the current
> setting if BOOL is not given.
> 
> If an error occurs blocking will return undef and $! will be set.
> ​as in
> $io->blocking( 0 ) or croak "$!: io->blocking ( 0 )";
> 
> ​the "sub init" for SSL-capable netcat script "scnc" does :
> 
>   $SIG{INT}  = sub { $self->exit };
>   $SIG{CHLD} = 'IGNORE';
> 
>   STDOUT->blocking(0);
>   STDOUT->autoflush(1);
>   STDIN->blocking(0);
>   STDIN->autoflush(1);
> ​
> 
> _______________________________________________
> Boston-pm mailing list
> [email protected]
> http://mail.pm.org/mailman/listinfo/boston-pm

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.