Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 9th, 2006, 4:12 AM   #1
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 145
Rep Power: 0 a thing is on a distinguished road
reading stdin

I want to read stdin and put it in array foo, but I don't want to bring up the prompt if stdin is empty, like
read -a foo
does. If "-t 0" is passed to read, then it doesn't put stdin into $foo when there's actually something in stdin.
a thing is offline   Reply With Quote
Old Dec 9th, 2006, 9:16 PM   #2
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 145
Rep Power: 0 a thing is on a distinguished road
I found a way:
if ! [ -t 0 ]; then
	read -a foo
fi

Finished script (until I find another thing I should but haven't implemented): http://athingis.boldlygoingnowhere.org/software/prefix
a thing is offline   Reply With Quote
Old May 20th, 2009, 4:38 AM   #3
k2t0f12d
Newbie
 
Join Date: May 2009
Posts: 1
Rep Power: 0 k2t0f12d is on a distinguished road
Re: reading stdin

myarray=( $( cat /dev/stdin ) )
k2t0f12d is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading character input into an array (raw mode) shoeyfighter C 3 Nov 2nd, 2006 3:49 PM
c++ reading from a file ... programmingnoob C++ 8 Apr 22nd, 2006 6:17 PM
CPU Usage goes to 100% when pthread_cond_wait is being used zen_buddha C++ 1 Oct 13th, 2005 5:59 AM
Resetting stdin after EOF o0zi C 2 May 23rd, 2005 11:25 PM
How do I direct stdout to the screen, stdin to the keyboard? fzrrider C++ 0 Feb 13th, 2005 5:33 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:16 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC