From: Alexandre Ferrieux on 25 May 2010 12:40 On May 25, 4:54 pm, hresquiveloa <hresquive...(a)gmail.com> wrote: > Hi. Can anyone help me to understand why the script shown below will > not work as expected? > > foreach line {CAPEMEND/FOR-UP.AT2 CAPEMEND/FOR000.AT2 CHICHI/CHY025- > W.AT2} { > exec bash -c "curl -Ohttp://peer.berkeley.edu/smcat/data/ath/$line" > > } > > The script goal is to download a set of files (accelerograms) from the > PEER Strong Motion Database... Thank you! The loop is broken because bash spits out to stderr, which is interpreted as an error by Tcl. The error message given is simply the stderr output from curl, which is easily confused with its normal behavior... To convince yourself of this interpretation, just type puts $::errorInfo after the trial. To fix this, add 2>@ stderr to the bash -c invocation: exec bash -c "curl -O http://peer.berkeley.edu/smcat/data/ath/$line" 2>@ stderr You'll get the same progress info on the console, but (1) it will flow in real time (2) it will not generate a Tcl error (3) it will go through all 3 rounds of the loop :) -Alex
From: Fandom on 25 May 2010 13:02 If haven't it working yet you can try: foreach line {CAPEMEND/FOR-UP.AT2 CAPEMEND/FOR000.AT2 CHICHI/CHY025- W.AT2} { if {[catch {exec curl -O http://peer.berkeley.edu/smcat/data/ath/$line} error]} { puts "Error: $error" } }
From: hresquiveloa on 25 May 2010 13:36 Alex, thank you very much for your help. Your workaround works just as you described!
From: hresquiveloa on 25 May 2010 13:38
Andres, thank you very much for your help. Everything is working now. Thanks for your time. |