Fixing stdin inside a redirected loop...

In this group, it is an FGA that one should so:

    commandThatGeneratesTheFilenames | while read x ...

instead of the more common:

    for i in ...

because of the problems of filenames that spaces and other weird characters.

However, one downside to the "while" method is that inside the loop,
stdin is now coming from the pipe, and commands that we execute inside
the loop, that expect a normal stdin, will misbehave.

Workarounds:
    1) append "< /dev/tty" to each command
    2) enclose the commands in parens and redirect that.  I.e.:

	commandThatGeneratesTheFilenames | while read x;do
	    (cmd1;cmd2;cmd3;...) < /dev/tty
	    done

Method 2 is nice and seems to work fine, but I am wondering if there is
any hidden cost to it and if there is any more elegant/effcient way to
do this.

-- 
Just for a change of pace, this sig is *not* an obscure reference to
comp.lang.c...

0
gazelle
7/20/2010 12:13:50 PM
comp.unix.shell 15270 articles. 0 followers. Post Follow

18 Replies
5022 Views

Similar Articles

[PageSpeed] 55
Kenny McCormack wrote:

> In this group, it is an FGA that one should so:
> 
>     commandThatGeneratesTheFilenames | while read x ...
> 
> instead of the more common:
> 
>     for i in ...
> 
> because of the problems of filenames that spaces and other weird
> characters.
> 
> However, one downside to the "while" method is that inside the loop,
> stdin is now coming from the pipe, and commands that we execute inside
> the loop, that expect a normal stdin, will misbehave.
> 
> Workarounds:
>     1) append "< /dev/tty" to each command
>     2) enclose the commands in parens and redirect that.  I.e.:
> 
> commandThatGeneratesTheFilenames | while read x;do
> (cmd1;cmd2;cmd3;...) < /dev/tty
> done

I think (at least with bash) it's possible to use a file descriptor other 
than the standard ones, and use read -u to read from that descriptor. This 
way, standard descriptors (0, 1 and 2) inside the loop are not affected.

Something like

exec 3< <(command)

while read -u 3 line; do
  # unaffected commands here...
done

exec 3>&-


I understand it's a highly nonstandard solution, but, depending on where it 
has to run, it might be applicable.
0
pk
7/20/2010 12:55:19 PM
In article <i246br$vjs$1@speranza.aioe.org>, pk  <pk@pk.invalid> wrote:
....
>I think (at least with bash) it's possible to use a file descriptor other 
>than the standard ones, and use read -u to read from that descriptor. This 
>way, standard descriptors (0, 1 and 2) inside the loop are not affected.
>
>Something like
>
>exec 3< <(command)
>
>while read -u 3 line; do
>  # unaffected commands here...
>done
>
>exec 3>&-
>
>I understand it's a highly nonstandard solution, but, depending on where it 
>has to run, it might be applicable.

Very interesting.  As readers of my posts know, I'm not a "standards
jockey", so don't take what I say next as the typical SJ jockeying...

That said,
    1) The above works if I invoke "bash" as "bash".
    2) (However) It does not work if I invoke "bash" as "sh"
    3) It doesn't work under "dash" (which is what /bin/sh on some Linux
	boxes actually is).

Anyway, as I said, it is quite intriguing.

-- 
Just for a change of pace, this sig is *not* an obscure reference to
comp.lang.c...

0
gazelle
7/20/2010 2:12:57 PM
In article <i24at9$rc5$1@news.xmission.com>,
Kenny McCormack <gazelle@shell.xmission.com> wrote:
....
>That said,
>    1) The above works if I invoke "bash" as "bash".
>    2) (However) It does not work if I invoke "bash" as "sh"
>    3) It doesn't work under "dash" (which is what /bin/sh on some Linux
>	boxes actually is).
>
>Anyway, as I said, it is quite intriguing.

I forgot to add, the important thing, which is that your solution,
unfortunately, does not work on the targetted system (which is a Linux
system without bash - yes, they exist).  So, I am still curious about
the questions raised in the OP - is there any hidden cost (inefficiency)
to using the ()</dev/tty method, and are there any (other) alternatives?

-- 
"We should always be disposed to believe that which appears to us to be
white is really black, if the hierarchy  of the church so decides." 

    - Saint Ignatius Loyola (1491-1556) Founder of the Jesuit Order -

0
gazelle
7/20/2010 2:24:37 PM
On Tue, 20 Jul 2010 14:12:57 +0000 (UTC) gazelle@shell.xmission.com (Kenny
McCormack) wrote:

> In article <i246br$vjs$1@speranza.aioe.org>, pk  <pk@pk.invalid> wrote:
> ...
> >I think (at least with bash) it's possible to use a file descriptor
> >other than the standard ones, and use read -u to read from that
> >descriptor. This way, standard descriptors (0, 1 and 2) inside the loop
> >are not affected.
> >
> >Something like
> >
> >exec 3< <(command)
> >
> >while read -u 3 line; do
> >  # unaffected commands here...
> >done
> >
> >exec 3>&-
> >
> >I understand it's a highly nonstandard solution, but, depending on where
> >it has to run, it might be applicable.
> 
> Very interesting.  As readers of my posts know, I'm not a "standards
> jockey", so don't take what I say next as the typical SJ jockeying...
> 
> That said,
>     1) The above works if I invoke "bash" as "bash".
>     2) (However) It does not work if I invoke "bash" as "sh"
>     3) It doesn't work under "dash" (which is what /bin/sh on some Linux
> 	boxes actually is).

Standards jockey or not, if that is where it has to run, you definitely need
a standard solution.

0
pk
7/20/2010 5:06:56 PM
Kenny McCormack wrote:

> In this group, it is an FGA that one should so:
> 
>     commandThatGeneratesTheFilenames | while read x ...
> 
> instead of the more common:
> 
>     for i in ...
> 
> because of the problems of filenames that spaces and other weird
> characters.
> 
> However, one downside to the "while" method is that inside the loop,
> stdin is now coming from the pipe, and commands that we execute inside
> the loop, that expect a normal stdin, will misbehave.

Name one, and I am pretty sure that I can tell you the switch that will 
prevent it from considering stdin.  For example, ssh(1) has `-n'.

-- 
PointedEars
0
Thomas
7/21/2010 12:14:38 AM
Kenny McCormack wrote:

> In this group, it is an FGA that one should so:
> 
>     commandThatGeneratesTheFilenames | while read x ...
> 
> instead of the more common:
> 
>     for i in ...
> 
> because of the problems of filenames that spaces and other weird
> characters.

No, the foregone assumption (FGA is not a common Usenet acronym -- shouldn't 
that be "foregone conclusion" anyway?) is that find(1) with `-exec', or 
`find' with xargs(1), are safer than both approaches.

Usenet rule of thumb: Never ask what is better; bottom line is that better 
is what works for you.  Ask instead what is more efficient aso. given a 
specific context.

-- 
PointedEars
0
Thomas
7/21/2010 12:24:50 AM
In article <i243tu$l8g$1@news.xmission.com>,
Kenny McCormack <gazelle@shell.xmission.com> wrote:
>In this group, it is an FGA that one should so:
>
>    commandThatGeneratesTheFilenames | while read x ...
>
>instead of the more common:
>
>    for i in ...
>
>because of the problems of filenames that spaces and other weird characters.
>
>However, one downside to the "while" method is that inside the loop,
>stdin is now coming from the pipe, and commands that we execute inside
>the loop, that expect a normal stdin, will misbehave.
>
>Workarounds:
>    1) append "< /dev/tty" to each command
>    2) enclose the commands in parens and redirect that.  I.e.:
>
>	commandThatGeneratesTheFilenames | while read x;do
>	    (cmd1;cmd2;cmd3;...) < /dev/tty
>	    done
>
>Method 2 is nice and seems to work fine, but I am wondering if there is
>any hidden cost to it and if there is any more elegant/effcient way to
>do this.

    Unless you specifically want to read from the controlling tty rather than
    the standard input, it's always better to save the standard input to
    another fd and then read from it.

    {
	commandThatGeneratesTheFilenames |
	    while read x <&4; do
		cmd1
		cmd2
		cmd3
	    done 4<&0 0<&3
    } 3<&0

    In modern shells (ksh93/bash/zsh) you can do:

    while read -u3 x; do
	cmd1
	cmd2
	cmd3
    done 3< <(commandThatGeneratesTheFilenames)

	John
-- 
John DuBois  spcecdt@armory.com  KC6QKZ/AE  http://www.armory.com/~spcecdt/
0
spcecdt
7/21/2010 4:56:01 PM
In article <B_qdnbdAifw8u9rRnZ2dnUVZ_s6dnZ2d@speakeasy.net>,
John DuBois <spcecdt@armory.com> wrote:
....
>    Unless you specifically want to read from the controlling tty rather than
>    the standard input, it's always better to save the standard input to
>    another fd and then read from it.
>
>    {
>	commandThatGeneratesTheFilenames |
>	    while read x <&4; do
>		cmd1
>		cmd2
>		cmd3
>	    done 4<&0 0<&3
>    } 3<&0

What's the difference between enclosing the cmds in {} vs. ()?

-- 
Faced with the choice between changing one's mind and proving that there is
no need to do so, almost everyone gets busy on the proof. 

    - John Kenneth Galbraith -

0
gazelle
7/21/2010 5:45:28 PM
On 2010-07-21, Kenny McCormack wrote:
> In article <B_qdnbdAifw8u9rRnZ2dnUVZ_s6dnZ2d@speakeasy.net>,
> John DuBois <spcecdt@armory.com> wrote:
> ...
>>    Unless you specifically want to read from the controlling tty rather than
>>    the standard input, it's always better to save the standard input to
>>    another fd and then read from it.
>>
>>    {
>>	commandThatGeneratesTheFilenames |
>>	    while read x <&4; do
>>		cmd1
>>		cmd2
>>		cmd3
>>	    done 4<&0 0<&3
>>    } 3<&0
>
> What's the difference between enclosing the cmds in {} vs. ()?

   Commands in ( ) are executed in a subshell.


-- 
   Chris F.A. Johnson, author           <http://shell.cfajohnson.com/>
   ===================================================================
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)

0
Chris
7/21/2010 7:05:00 PM
In article <8aoumsFvcrU2@mid.individual.net>,
Chris F.A. Johnson <cfajohnson@gmail.com> wrote:
>On 2010-07-21, Kenny McCormack wrote:
>> In article <B_qdnbdAifw8u9rRnZ2dnUVZ_s6dnZ2d@speakeasy.net>,
>> John DuBois <spcecdt@armory.com> wrote:
>> ...
>>>    Unless you specifically want to read from the controlling tty rather than
>>>    the standard input, it's always better to save the standard input to
>>>    another fd and then read from it.
>>>
>>>    {
>>>	commandThatGeneratesTheFilenames |
>>>	    while read x <&4; do
>>>		cmd1
>>>		cmd2
>>>		cmd3
>>>	    done 4<&0 0<&3
>>>    } 3<&0
>>
>> What's the difference between enclosing the cmds in {} vs. ()?
>
>   Commands in ( ) are executed in a subshell.

That's what I thought.  So, the answer to the original question, despite
all the other flurry, is simply: Yes, you should use {} rather than ().

-- 
"We should always be disposed to believe that which appears to us to be
white is really black, if the hierarchy  of the church so decides." 

    - Saint Ignatius Loyola (1491-1556) Founder of the Jesuit Order -

0
gazelle
7/21/2010 7:10:05 PM
Kenny McCormack wrote:

> Chris F.A. Johnson <cfajohnson@gmail.com> wrote:
>> On 2010-07-21, Kenny McCormack wrote:
>>> What's the difference between enclosing the cmds in {} vs. ()?
>>   Commands in ( ) are executed in a subshell.
> 
> That's what I thought.  So, the answer to the original question, despite
> all the other flurry, is simply: Yes, you should use {} rather than ().

No, the answer simply is, again, "it depends."  That is the part of software 
development that you do not seem to understand.

-- 
PointedEars
0
Thomas
7/21/2010 8:59:14 PM
On 2010-07-21, John DuBois wrote:
> In article <i243tu$l8g$1@news.xmission.com>,
> Kenny McCormack <gazelle@shell.xmission.com> wrote:
>>In this group, it is an FGA that one should so:
>>
>>    commandThatGeneratesTheFilenames | while read x ...
>>
>>instead of the more common:
>>
>>    for i in ...
>>
>>because of the problems of filenames that spaces and other weird characters.
>>
>>However, one downside to the "while" method is that inside the loop,
>>stdin is now coming from the pipe, and commands that we execute inside
>>the loop, that expect a normal stdin, will misbehave.
>>
>>Workarounds:
>>    1) append "< /dev/tty" to each command
>>    2) enclose the commands in parens and redirect that.  I.e.:
>>
>>	commandThatGeneratesTheFilenames | while read x;do
>>	    (cmd1;cmd2;cmd3;...) < /dev/tty
>>	    done
>>
>>Method 2 is nice and seems to work fine, but I am wondering if there is
>>any hidden cost to it and if there is any more elegant/effcient way to
>>do this.
>
>     Unless you specifically want to read from the controlling tty rather than
>     the standard input, it's always better to save the standard input to
>     another fd and then read from it.

   Why?

>     {
> 	commandThatGeneratesTheFilenames |
> 	    while read x <&4; do

   That will fail on filenames beginning or ending with spaces.

while IFS= read -r x <&4

> 		cmd1
> 		cmd2
> 		cmd3
> 	    done 4<&0 0<&3
>     } 3<&0
>
>     In modern shells (ksh93/bash/zsh) you can do:
>
>     while read -u3 x; do
> 	cmd1
> 	cmd2
> 	cmd3
>     done 3< <(commandThatGeneratesTheFilenames)
>
> 	John


-- 
   Chris F.A. Johnson, author           <http://shell.cfajohnson.com/>
   ===================================================================
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)

0
Chris
7/21/2010 9:30:36 PM
In article <4540035.MirdbgypaU@PointedEars.de>,
Thomas 'PointedEars' Lahn  <usenet@PointedEars.de> wrote:
>Kenny McCormack wrote:
>
>> Chris F.A. Johnson <cfajohnson@gmail.com> wrote:
>>> On 2010-07-21, Kenny McCormack wrote:
>>>> What's the difference between enclosing the cmds in {} vs. ()?
>>>   Commands in ( ) are executed in a subshell.
>> 
>> That's what I thought.  So, the answer to the original question, despite
>> all the other flurry, is simply: Yes, you should use {} rather than ().
>
>No, the answer simply is, again, "it depends."  That is the part of software 
>development that you do not seem to understand.

You funny.

(And I've not even seen any pix of you and you funny ears!)

-- 
> No, I haven't, that's why I'm asking questions. If you won't help me,
> why don't you just go find your lost manhood elsewhere.

CLC in a nutshell.

0
gazelle
7/21/2010 9:34:20 PM
On 2010-07-21, Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote:
> No, the foregone assumption (FGA is not a common Usenet acronym

"Frequently Given Answer", used by some guy whose name I've forgotten
to refer to things he maintains in a format chosen to prevent people from
rebutting the idiocy therein.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
0
Seebs
7/21/2010 9:49:57 PM
Kenny McCormack wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Kenny McCormack wrote:
>>> Chris F.A. Johnson <cfajohnson@gmail.com> wrote:
>>>> On 2010-07-21, Kenny McCormack wrote:
>>>>> What's the difference between enclosing the cmds in {} vs. ()?
>>>>   Commands in ( ) are executed in a subshell.
>>> That's what I thought.  So, the answer to the original question, despite
>>> all the other flurry, is simply: Yes, you should use {} rather than ().
>> No, the answer simply is, again, "it depends."  That is the part of
>> software development that you do not seem to understand.
> 
> You funny.

It was not my intention to amuse you, but to make you think twice.  BTW, in 
responding like this you are also making a fool of yourself with regard to 
grammar.

> (And I've not even seen any pix of you and you funny ears!)
 
I have not seen a photo of you either.  So what?
-- 
PointedEars
0
Thomas
7/22/2010 12:31:09 AM
Seebs wrote:

> Thomas 'PointedEars' Lahn wrote:
>> No, the foregone assumption (FGA is not a common Usenet acronym
> 
> "Frequently Given Answer", used by some guy whose name I've forgotten
> to refer to things he maintains in a format chosen to prevent people from
> rebutting the idiocy therein.

Thanks.  In ten years of regular Usenet participation, in and outside of the 
Big 8, I had never come across that acronym.  It is not in the Jargon File 
either.  So I doubt it is more than his original research.

-- 
PointedEars
0
Thomas
7/22/2010 9:44:28 AM
In article <8ap77sFvcrU3@mid.individual.net>,
Chris F.A. Johnson <cfajohnson@gmail.com> wrote:
>On 2010-07-21, John DuBois wrote:
>> In article <i243tu$l8g$1@news.xmission.com>,
>> Kenny McCormack <gazelle@shell.xmission.com> wrote:
>>>Workarounds:
>>>    1) append "< /dev/tty" to each command
>>>    2) enclose the commands in parens and redirect that.  I.e.:
>>>
>>>	commandThatGeneratesTheFilenames | while read x;do
>>>	    (cmd1;cmd2;cmd3;...) < /dev/tty
>>>	    done
>>>
>>>Method 2 is nice and seems to work fine, but I am wondering if there is
>>>any hidden cost to it and if there is any more elegant/effcient way to
>>>do this.
>>
>>     Unless you specifically want to read from the controlling tty rather than
>>     the standard input, it's always better to save the standard input to
>>     another fd and then read from it.
>
>   Why?

Because the standard input may not be the controlling tty (if the program is
piped or redirected into, or started from an environment with no controlling
tty, etc).

	John
-- 
John DuBois  spcecdt@armory.com  KC6QKZ/AE  http://www.armory.com/~spcecdt/
0
spcecdt
7/22/2010 3:03:54 PM
2010-07-20, 12:13(+00), Kenny McCormack:
> In this group, it is an FGA that one should so:
>
>     commandThatGeneratesTheFilenames | while read x ...
>
> instead of the more common:
>
>     for i in ...
>
> because of the problems of filenames that spaces and other weird characters.

After

IFS='
' # NL
set -f
for i in $(commandThatGeneratesTheFilenames); do...

shouldn't be a problem (except that the loop only starts when
commandThatGeneratesTheFilenames finishes).

Other solution (not any better either than the ones that have
already been given):

while IFS= read <&3 -r i; do
   ...
done 3<<EOF
$(commandThatGeneratesTheFilenames)
EOF

{
  commandThatGeneratesTheFilenames |
    while IFS= read <&3 -r i; do
      ...
    done 3<&0 <&4 4<&-
} 4<&0

as already given would be the best one. If you're picky, you may
write it:

{
  commandThatGeneratesTheFilenames 4<&- |
    while IFS= read <&3 -r i; do
    {
      ...
    } 3<&-
    done 3<&0 <&4 4<&-
} 4<&0

or:

{
  commandThatGeneratesTheFilenames 4<&- |
    while IFS= read -r i 4<&-; do
    {
      ...
    } <&4 4<&-
    done
} 4<&0

-- 
Stephane
0
Stephane
7/26/2010 4:57:51 PM
Reply:
Similar Artilces:

How jump inside page?
** sample: how can i make it work? <!DOCTYPE html> <html lang="en"> <head> </head> <body> <!-- sample Does NOT go to "skipp" --> <div class="grid_13 padtop"> <h3>"Get in Touch"..</h3> <script> window.location.replace('s.html#skipp'); </script> <form id="contact-form"> <div class="success"> Contact form submitted!<br> <strong>We will be in touch soon.</strong></div> ...

[News] More Price-Fixing Stories
Samsung US executive gets 8 months for price-fixing ,----[ Quote ] | A marketing executive with the U.S. unit of Samsung Electronics Co. | Ltd. agreed to plead guilty and serve prison time for taking part in | price-fixing in the computer memory chip business, the U.S. Justice | Department said Thursday. `---- http://biz.yahoo.com/bizj/060921/1350150.html?.v=1 Reminds me of: Lawsuit Against Microsoft Set for Court ,----[ Quote ] | The case claims Microsoft violated Iowa's antitrust laws and harmed | customers by illegally overcharging for its software, by denying class | members free ...

Sr. SAP resource
hi, I am looking for a Sr.SAP with good knowledge in Fixed Assets / SME. if suitable kindly mail me your resume and rates. Email your resume to : carmelc@gmail.com. REQUIREMENT: Sr. SAP Resource -- Fixed Assets GURU // SME NOT looking for an AP/AR resource w/some fixed assets Rate: Best Start: ASAP (this week or early next is required) Duration: 9/30/05 w/possibility of extension Location: OH. ...

tcl 8.4.12 spin loop with solaris 10
We are running 64 bit tclsh 8.4.12 on Solaris 10 sparc machine and have some C++ libraries loaded as packages. We compile tclsh with threads disabled as we do not use the tcl thread package. Sometimes after loading up the system with a lot of job processing (open, close socket and returning reply to client sockets), we found tclsh to be in some heavy spin loop where it is polling (calling pollsys) all the time. cpu usage jumps from 10% to 45%. A lot of memset and memcpy calls are also bing made. We also have tcl c library package build on top of globus. When we load this package and run jobs...

US-TX-Austin: Inside Sales Rep., Inside Sales Background or Cold Calling Exp., c (45354114403)
US-TX-Austin: Inside Sales Rep., Inside Sales Background or Cold Calling Exp., c (45354114403) ============================================================================================== Position: Sales Rep. Reference: ZYD00005 Location: Austin TX Duration: Contract to Perm Skills: Inside Sales Rep Background or Cold Calling Exp. Outgoing Self-Motivated Strong Personal Character Exceptional Values Strong Personality Team Player Good Perseverance ...

Sockets with fixed IP address
I am developing and testing a dedicated LAN composed of just two Windows computers with Ethernet adapters. The application will deal with UDP only. No TCP. For various reasons, I would like to bypass the DNS stuff and use a statically defined IP address in the "server" side of the UDP connection. (The "server" will eventually be replaced with an embedded Ethernet device with limited resources.) The trouble is, I seem unable to use the Windows Sockets API to force a fixed IP address (10.10.6.100) in the "server". Evidence is that after calling bind a...

When is M$ meta file fix(just issued) not a fix?
With the recent "fix" of course it appears. http://www.techweb.com/article/showArticle.jhtml?articleId=175802806&pgno =1 ust days after Microsoft rushed out a patch for a bug in Windows Metafile (WMF) image processing, a security company has warned customers that multiple memory corruption vulnerabilities in the same rendering engine could leave users open to attack. "An attacker may leverage these issues to carry out a denial-of-service attack or execute arbitrary code," Symantec said in a vulnerability alert issued through its DeepSight Management System. The...

Fixing the fix fixes.
Sad. Someday in the distant future, they might get it right. Maybe with OSXII - but it's doubtful. ...

boolean loop optimisation
If I wrote some code like this: for ( int i=0; i<n; i++ ) { if ( x ) { a( i ); } else { b( i ); } } A clever compiler might notice that x in invariant inside the loop, and note really does not need to test x inside the loop. It can replace that code with something like this: if ( x ) for ( int i=0; i<n; i++ ) { a( i ); } else for ( int i=0; i<n; i++ ) { b( i ); } What is that called? -- Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glo...

Loop until condition is true
Hi there, There is always a "nice" way to do things in Python but this time I can't find one. What I'm trying to achieve is a conditionnal loop of which the condition test would be done at the end so the loop is executed at least once. It's some way the opposite of "while". So far, all I got is: while True: some(code) if final_condition is True: break # # What I don't find so "nice" is to have to build an infinite loop only to break it. Is there a better recipe? -- ================== Remi Villatel maxilys_@_tele2.fr ===============...

parallel interpreter/db problem. transaction didn't fix.
mysql_query("START TRANSACTION", $link2); $q2=mysql_query("SELECT pictures.pid AS pid FROM pictures,counter WHERE pictures.pid>counter.pid LIMIT 1", $link2); if ($row2=mysql_fetch_assoc($q2)) { mysql_query("UPDATE counter SET pid=$row2[pid]", $link2); $n=$row2['pid']; } else { //reached end of table. mysql_query("UPDATE counter SET pid=1", $link2); $n=1; } mysql_free_result($q2); mysql_query("COMMIT", $link2); the transaction makes no difference in the outcome. I've even tried locking the tables, but tha...

Re: [ace-users] ACE_Thread_Timer_Queue_Adapter: Timer loop runsatincorrect speed
=20 > -----Original Message----- > From: ace-users-bounces@cse.wustl.edu=20 > [mailto:ace-users-bounces@cse.wustl.edu] On Behalf Of Caleb Epstein > Sent: 09 November 2006 18:27 > To: Matthew Gillen > Cc: ace-users@cse.wustl.edu > Subject: Re: [ace-users] ACE_Thread_Timer_Queue_Adapter:=20 > Timer loop runsatincorrect speed >=20 > On 11/9/06, Caleb Epstein <caleb.epstein@gmail.com> wrote: >=20 > > If I schedule a recurring timer for anything less than=20 > 20ms, it fires=20 > > at approximately 20ms intervals, sometimes 15ms....

svgalib and redirecting stdout
I run a linux program from a DOS prompt on my (windows) host machine using ssh <targetMachine> programName. The program uses the svgalib graphics library. std::cout commands print on the DOS window until svgalib's vga_init() is called. Then I see [svgalib: allocated virtual console #10]. After this my program draws some graphics on the linux target's screen and my windows host's DOS window no longer prints any std::cout commands. Is there any way I can keep std::cout commands appearing on my host DOS window? Thanks. ...

Fixing fixes
OSX 10.5.2 - a really great OS- BWAHAAAHAAAHAAAA. I personally like the "Scotch Tape Fix. Apple confirms "closed-lid" issue is a known bug Slow LAN transfers under Mac OS X 10.5.2 Mac OS X Tiger (10.4.x), PowerBook users continue suffer from missing first letter Mac OS X 10.5.2/Leopard Graphics Update 1.0: Missing display resolutions and wake-from sleep Leopard Graphics Update 1.0: Repeatable freezes, uninstalling fixes Apple TV 2.0: More fixes for problems updating Aperture 1.5.x does not benefit from Mac OS X 10.5.2 RAW improvements Boosting iPhone signal streng...

Dynamically allocating a fixed-size multidimensional array?
Actually, I'm not even sure it's possible to dynamically allocate a fixed size one dimensional array. So here's the problem: I have a type 'board' defined as so: typedef char board[8][8] and I am supposed to write a function with the following prototype: Board *new_board(); which would require me to use malloc for allocation. I've tried many different things that I'd be ashamed to post here but have found no solution. The problem is that it doesn't seem possible to cast a char* or char** to a fixed length array (e.g. char[8] or char[8][8] or board in this cas...

Fixed Weight Sorting
Hi all, I'm trying to simulate a fixed weght machine. This machine has two entry points with grapes that have two different probabilistic distributions. Then a work center pick from several queues a combination so grape1+grape2=target+-tol. Anyone is familiar with this kind of work? Best Regards, Jaime ...

Timing off between two loops
I am writing a VI that is writing a sine wave to the DAQ, reading the DAQ, and Writing the data to a file.&nbsp; I am using a PCI-MIO-16E DAQ card.&nbsp; My problem is that the timing is off.&nbsp; the written data is not showing a true sine wave.&nbsp; it's is streched intially and then compresses.&nbsp; I would like a to improve the timing between my two loops.&nbsp; Any Ideas. &nbsp; Greg (the one who is lost in his own spaghetti) Spectrum Acquistion Program.vi: http://forums.ni.com/attachments/ni/170/193826/1/Spectrum Acquistion Program.vi ...

(InfoSnapV8)
Hi, Fixed quite a few trouble reports, and in fact my pile of trouble reports looks very empty at the moment :-) What is fixed: http://www.ustation.se/InfoSnapV8/Sordid.TXT Free download: http://www.ustation.se Have a lot of fun, /Chris Zakrewsky Team uStation AB SWEDEN ...

ledmac apparatus with fixed content
L.S. For a critical edition I would need a first apparatus with fixed content in order to cite all manuscripts on one line (of each single page). My hope was to be able to (mis)use a footnote apparatus uniquely for the purpose of displaying this fixed line and gave it an appropriate name \let\sigla=\Afootnote Then I hoped to be able to use the afterpage package to insert the apparatus \afterpage{\edtext{}{\sigla{p q r s}} but this was not succesful. A second attempt was to define a pagestyle with the following \makepagestyle{edition} \makeevenhead{edition}{}{}{\edtext{}{\sigla{p q r ...

How to vectorize an indexing for loop?
Hi, I'm trying to figure out if there's an easy and efficient way to convert a particular kind of for loop into some sort of vectorized statement. The for loop creates a column vector from a 2D matrix, selecting one element per row. For example, let's say the variable index says which element I want from each row. Normally, I'd write something like this: for i=1:nColumns ySubset(i) = y(i, index(i)); end If I try to write this as a single statement with indexing, e.g. ySubset1 = y(:, index); I incorrectly take entire columns from y. I did realize that the diagonal of ySu...

need help fixing x windows
i have freebsd7 installed on a laptop Fijitsu siemens C series lifebook 1020. I use a "savage" driver.I am having problems in getting x to work properly and dont understand how to fix it. The system complains that certain modules are already loaded. 1. This is the xorg.conf file that i use: ------------------------------------------- Section "ServerLayout" Identifier "X.org Configured" Screen 0 "Screen0" 0 0 InputDevice "Mouse0" "CorePointer" InputDevice "Keyboard0" "CoreKeyboard" ...

realNetworks fixes Linux realPlayer flaw
RealNetworks Fixes Linux RealPlayer Flaw Gregg Keizer Oct 03 2005 [...] Both RealPlayer and Helix Player for Linux have been patched against a vulnerability that could let a hacker execute commands remotely once he'd convinced the user to open a malformed .rp (realpix) or .rt (realtext) file ... http://www.informationweek.com/story/showArticle.jhtml?articleID=171202674 ...

devpi-server-0.8.2: bug fixes for the pypi.python.org caching server
just did a release of devpi-server-0.8.2, the fast pypi.python.org caching server. 0.8.2 fixes a bug which prevented the installation of some packages. If you encounter any such problems, please report it at: https://bitbucket.org/hpk42/devpi-server/issues or on #pylib on freenode. A new release will quickly fix it - we had four releases in six days now :) More information on installing and deploying devpi-server here: http://pypi.python.org/pypi/devpi-server best, holger ...

Optimizing multiple loops w/ TCP/IP Comm
Hello, I am currently working on developing data collection/analysis VI over TCP/IP. I need to read data at a 100Hz rate from my DUT which to me seems fairly quick for LV. So I am using 3 loops to handle all the interactions. One loop has an event structure to handle interface with the front panel controls. One loop to handle the main task of polling the TCP/IP buffer. The last loop handles the periodic (approx every 5 sec) "Keep alive" message LV must send to the DUT to keep it outputting ethernet messages. I was thinking of another loop to setup the DUT and support equipment (RF So...

for loop question #2
hi.. basic foor/loop question.. i can do: for a in foo print a if i want to do something like for a, 2, foo print foo where go from 2, to foo.. i can't figure out how to accomplish this... can someone point me to how/where this is demonstrated... found plenty of google for for/loop.. just not this issue.. thanks -bruce just do: for a in range(2, foo+1): print a range(a, b) gives [a, a+1, a+2, ..., b-2, b-1] bruce schrieb: > hi.. > > basic foor/loop question.. > > i can do: > > for a in foo > print a > > if i want to do somethi...