Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #198648

Re: non-blocking stdin from bash

From <tomas@tuxteam.de>
Newsgroups linux.debian.user
Subject Re: non-blocking stdin from bash
Date 2018-08-12 00:50 +0200
Message-ID <wlKRP-28u-1@gated-at.bofh.it> (permalink)
References <wlKf8-1W9-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, Aug 11, 2018 at 06:08:34PM -0400, Jim Popovitch wrote:
> Hello!
> 
> What's the best way to grab anything that's in stdin into a variable
> inside a bash script, but won't block if stdin is null?

I think read is your friend (at least in bash). It has an option
- -t <timeout>, which you can set to zero, for it to just grab what's
available at the moment without waiting (cf "help read" while in
the bash for more details, like setting a delimiter, etc.)

HTH
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAltvZ8gACgkQBcgs9XrR2kZ4XwCeKD4PgANQHP+QTuB+LtMPGdfP
blYAn3ovvpi+8Cx+vlaQ/5oAafdxlgww
=BWci
-----END PGP SIGNATURE-----

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

non-blocking stdin from bash Jim Popovitch <jim@k4vqc.com> - 2018-08-12 00:10 +0200
  Re: non-blocking stdin from bash <tomas@tuxteam.de> - 2018-08-12 00:50 +0200
    Re: non-blocking stdin from bash Jim Popovitch <jim@k4vqc.com> - 2018-08-12 07:30 +0200
      Re: non-blocking stdin from bash <tomas@tuxteam.de> - 2018-08-12 10:40 +0200
        Re: non-blocking stdin from bash Jim Popovitch <jim@k4vqc.com> - 2018-08-12 18:40 +0200
          Re: non-blocking stdin from bash <tomas@tuxteam.de> - 2018-08-12 19:50 +0200
            Re: non-blocking stdin from bash Jim Popovitch <jim@k4vqc.com> - 2018-08-12 20:00 +0200
              Re: non-blocking stdin from bash <tomas@tuxteam.de> - 2018-08-12 22:00 +0200
              Re: non-blocking stdin from bash Richard Hector <richard@walnut.gen.nz> - 2018-08-13 00:20 +0200
                Re: non-blocking stdin from bash Jim Popovitch <jim@k4vqc.com> - 2018-08-13 00:50 +0200
                Re: non-blocking stdin from bash Greg Wooledge <wooledg@eeg.ccf.org> - 2018-08-13 15:00 +0200
                Re: non-blocking stdin from bash Jim Popovitch <jim@k4vqc.com> - 2018-08-13 16:40 +0200
                Re: non-blocking stdin from bash Greg Wooledge <wooledg@eeg.ccf.org> - 2018-08-13 16:50 +0200
                Re: non-blocking stdin from bash Jim Popovitch <jim@k4vqc.com> - 2018-08-13 17:00 +0200
                Re: non-blocking stdin from bash Dan Purgert <dan@djph.net> - 2018-08-13 17:10 +0200
                Re: non-blocking stdin from bash Greg Wooledge <wooledg@eeg.ccf.org> - 2018-08-13 17:10 +0200
                Re: non-blocking stdin from bash Dan Purgert <dan@djph.net> - 2018-08-13 17:30 +0200
                Re: non-blocking stdin from bash Richard Hector <richard@walnut.gen.nz> - 2018-08-14 08:10 +0200

csiph-web