Re: Ksh output garbled/out-of-sync



On May 10, 2:56 pm, govindrjuj...@xxxxxxxxx wrote:
On May 10, 1:17 pm, govindrjuj...@xxxxxxxxx wrote:





On May 10, 9:00 am, Janis <janis_papanag...@xxxxxxxxxxx> wrote:

On 10 Mai, 11:54, Bill Marcum <marcumb...@xxxxxxxxxxxxx> wrote:

On 9 May 2007 19:20:15 -0700, govindrjuj...@xxxxxxxxx

<govindrjuj...@xxxxxxxxx> wrote:

On May 9, 8:28 pm, govindrjuj...@xxxxxxxxx wrote:
Can somebody explain this ? -- thx

/tmp> cat ./1.sh
#!/bin/ksh

for name in 1 2 3 4 5 6 7 8 9 10
do
/bin/echo "<$name>"
/bin/cat /etc/passwd | head -1 | tail
done

/tmp> ./1.sh
<1>
root:x:0:1:HOSTNAME Super-User:/:/usr/bin/ksh
<2>
root:x:0:1:HOSTNAME Super-User:/:/usr/bin/ksh
<3>
root:x:0:1:HOSTNAME Super-User:/:/usr/bin/ksh
<4>
root:x:0:1:HOSTNAME Super-User:/:/usr/bin/ksh
<5>
root:x:0:1:HOSTNAME Super-User:/:/usr/bin/ksh
<6>
root:x:0:1:HOSTNAME Super-User:/:/usr/bin/ksh
<7>
root:x:0:1:HOSTNAME Super-User:/:/usr/bin/ksh
<8>
<9>
root:x:0:1:HOSTNAME Super-User:/:/usr/bin/ksh
root:x:0:1:HOSTNAME Super-User:/:/usr/bin/ksh
<10>
root:x:0:1:HOSTNAME Super-User:/:/usr/bin/ksh

Looks like problem with "head". Happening on Solaris 5.8.

Try adding "wait" before "done". What version ofkshis this?
What happens if you use the builtin echo instead of /bin/echo?

--
Heard that the next Space Shuttle is supposed to carry several Guernsey cows?
It's gonna be the herd shot 'round the world.

And while experimenting; what's the result if you remove all
superfluous processs from

/bin/cat /etc/passwd | head -1 | tail

head -1 </etc/passwd

Does this also produce the disorderedoutput?

Janis- Hide quoted text -

- Show quoted text -

That suggestion worked. No more garbledoutput.

I ran the original script as-is on couple of more other systems with
Solaris 5.8. On some theoutputseems ok
and on some others, it gets unordered. I guess it varies with cpu
load. Whenever I am not able to reproduce the
problem, I just add few more "head -1" commands and theoutputgets
unordered.

I am leaning towards the possibilities that there is something wrong
with the configuration of our systems or
"head" is doing something mysterious with STDIN.- Hide quoted text -

- Show quoted text -

Did I mention that the behaviour is not consistent for each run ? I
modified the script to check for
several iterations. Here is what worked and what did not.

========================================
#!/bin/ksh

integer i=0
while [[ $i -lt 1000 ]]
do
echo "marker"

# unordered
# /bin/cat /etc/passwd | /bin/head -1 | /bin/tail

# ordered
# /bin/head -1 </etc/passwd | /bin/tail

# ordered
# /bin/head -1 /etc/passwd | /bin/tail

# ordered
# /bin/cat /etc/passwd | /bin/head -1 | /bin/tail
# wait

i=$i+1
done
========================================

When you open one of the commented blocks and run the script as ---

./1.sh | uniq | wc -l

It should print 2000. For the "unordered" block, it hardly prints
about 1600.- Hide quoted text -

- Show quoted text -

I am able to reproduce the problem on several Solaris 5.8 systems now.
It
is starting to look like a problem with ksh. The following code prits
a number
anywhere from 1900 to 2000.

integer i=0
while [[ $i -lt 1000 ]]
do
/bin/echo marker 2>&1
/bin/cat /etc/passwd 2>&1 | /bin/echo "this" 2>&1 | /bin/wc -
l 2>&1
i=$i+1
done > out 2>&1
uniq out | wc -l


.



Relevant Pages

  • Re: Ksh output garbled/out-of-sync
    ... I ran the original script as-is on couple of more other systems with ... On some theoutputseems ok ... When you open one of the commented blocks and run the script as --- ... For the "unordered" block, it hardly prints ...
    (comp.unix.shell)
  • Re: Merge filter inconsistant - MS Replication Problem.zip (0/1)
    ... I have attached the files you need to reproduce the problem. ... create_test_loc.sql - script to create test databases on subscriber ... create_test_rep.sql - script to create test databases on publisher ... fGetCurrentUserID.sql - script to create filter criteria function on ...
    (microsoft.public.sqlserver.replication)
  • Re: Query acting strangely
    ... script that can help me reproduce and diagnose the problem. ... A repro script consists of: ... the text of the query you're having trouble with. ...
    (microsoft.public.sqlserver.mseq)
  • Re: timing problem with pthread_mutex_unlock and lock
    ... to reproduce the problem, compile first the code, and run the script. ... the unlocking problem is easy, ... void function; ...
    (comp.programming.threads)
  • Re: timing problem with pthread_mutex_unlock and lock
    ... > to reproduce the problem, compile first the code, and run the script. ... it will hang under a certain interleaving. ... and execute it a lot with help of the bash script */ ...
    (comp.programming.threads)