3 Replies - 616 Views - Last Post: 06 February 2012 - 08:54 AM Rate Topic: -----

Topic Sponsor:

#1 cpmckinn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-February 12

Script hangs during/after "diff" command

Posted 03 February 2012 - 01:30 PM

Hello,
I have a script that fills an array in a 'for' loop with the output from a diff command. The script generally works, but the program inevitably hangs at some point in the loop before executing the line after the diff command. Furthermore, there seems to be no apparent rhyme or reason to when the program freezes--during one execution of the program, it will get stuck on a particular iteration of the loop, but it will have no problems with that item the next time around, or it will get stuck on an element that was successfully processed before.

I can also apparently goad the program into continuing its execution by killing the diff subprocess, but it's not clear whether the array is correctly filled with the output from diff in this case.

Any help would be greatly appreciated, thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Script hangs during/after "diff" command

#2 KYA  Icon User is offline

  • #include <beer.h>
  • member icon

Reputation: 2548
  • View blog
  • Posts: 18,734
  • Joined: 14-September 07

Re: Script hangs during/after "diff" command

Posted 04 February 2012 - 12:50 PM

Can we see the script?
Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008  Icon User is online

  • Coder-ian
  • member icon

Reputation: 1401
  • View blog
  • Posts: 7,361
  • Joined: 29-May 08

Re: Script hangs during/after "diff" command

Posted 04 February 2012 - 01:23 PM

Did you try attaching the Psychic Debugger to your process?
Was This Post Helpful? 1
  • +
  • -

#4 cpmckinn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-February 12

Re: Script hangs during/after "diff" command

Posted 06 February 2012 - 08:54 AM

View PostKYA, on 04 February 2012 - 12:50 PM, said:

Can we see the script?


Of course, my mistake. Here is a condensed version that still displays the problematic behavior.
for d in $dir1/*
do
  dirname=`basename $d`
  echo $dirname
  p_dates=(`diff <(ls ./$dir1/$dirname/$dir2) <(ls $dir3 | xargs -I {} basename {} .txt | cut -c 8-) | sed 's/^> //g' | awk '{if (!($0 ~ /[a-z]/)) print}'`)
  len=${#p_dates[*]}
  echo $len
  for i in "${p_dates[@]}"
  do
    echo $i
  done
done


Also, in case it's relevant, I'm running this on cygwin.
Thanks again for your time.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1