LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 07-08-2009, 10:06 PM   #1
aryek
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
how can a program tell if it has stdin "waiting" to be read?


program p2:

if [[ .. we have stdin .. ]]; then
while read x; do
echo $x
done
else
echo "$@"
fi
 
Old 07-09-2009, 03:14 PM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 59
I would try something like this
Code:
#!/bin/bash

while read -t 1 x 
do echo $x
done
If nothing is discovered at the stdin in one second, the script exits. Probably not what you want though...
 
  


Reply

Tags
stdin


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting "Short read in buffer_copy" error with "dpkg" stalefries Linux - Software 6 03-24-2010 04:19 PM
"more" and "less" piped commands : the mystery of the hidden stdin ! Gerbillaz Linux - General 12 06-01-2009 08:23 AM
"gzip: stdin: unexpected end of file" when untaring Niflheim Linux - Newbie 8 11-12-2007 08:05 PM
Edit "read-only" /etc/fstab from "System Recovery#" (without boot cd?) charlweed Linux - General 1 12-31-2006 06:57 PM
"opt/openoffice.org/program/instdb.ins"can not be read?? masterguardian Linux - Software 1 08-07-2004 01:02 PM


All times are GMT -5. The time now is 09:28 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration