Operating System - HP-UX
1832978 Members
2461 Online
110048 Solutions
New Discussion

Re: How to create unbuffered file descriptor in ksh.

 
Richard Ray
Advisor

How to create unbuffered file descriptor in ksh.

How do I create a new file descriptor in ksh and make it unbuffered?
6 REPLIES 6
harry d brown jr
Honored Contributor

Re: How to create unbuffered file descriptor in ksh.

Richard, ksh allows you to create files, but you can't control wether it's buffered or not. Can you describe a little more as to what you are trying to do?

live free or die
harry
Live Free or Die
Santosh Nair_1
Honored Contributor

Re: How to create unbuffered file descriptor in ksh.

I believe Harry is correct, ksh does not give you this ability. Perl however does...any possibility of using Perl instead?

-Santosh
Life is what's happening while you're busy making other plans
Richard Ray
Advisor

Re: How to create unbuffered file descriptor in ksh.

Thanks guys. That's what I thought. My script uses isql to do a sql query in Sybase. There is another process waiting for the results. The query takes a couple of hours so I would like the search results returned as it's found not buffered and delivered in chunks. I guess Perl it is.
Santosh Nair_1
Honored Contributor

Re: How to create unbuffered file descriptor in ksh.

If you're going to use Perl with sybase, you might also want to look into SybPerl, which is perl with sybase extensions. Alternatively you could look at DBI/DBD which is a more abstract way of accessing Sybase within Perl.

Hope this helps.

-Santosh
Life is what's happening while you're busy making other plans
harry d brown jr
Honored Contributor

Re: How to create unbuffered file descriptor in ksh.

Santosh is correct, that the perl DB extensions are great. It makes "scripting" a lot easier. There are at least "extensions" for Informix, Oracle, and I believe mysql.

live free or die
harry
Live Free or Die
Wodisch
Honored Contributor

Re: How to create unbuffered file descriptor in ksh.

Hello Richard,

I would not like to spoil your perl-isms, but if your rae talking about "raw" vs. "cooked" mode of the shell input, you could use statements like these:

#!/usr/bin/ksh
key="."
old=$(stty -g)
stty -echo raw
while echo "Enter key by key:"
[ "$key" != "q" ]
do key=$(dd bs=1 count=1 2>/dev/null)
echo "key = $(echo '$key'|cat -v)"
done
stty $old

Not very elegant, ok ;-)
Wodisch