foreach line {CAPEMEND/FOR-UP.AT2 CAPEMEND/FOR000.AT2 CHICHI/CHY025-
W.AT2} {
exec bash -c "curl -O http://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!
foreach line {CAPEMEND/FOR-UP.AT2 CAPEMEND/FOR000.AT2 CHICHI/CHY025-
W.AT2} {
exec curl -O http://peer.berkeley.edu/smcat/data/ath/$line
}
You don't need 'bash -C' and if you put the curl command between
commas
exec will consider it a single 'word', not a command with parameters.
Andres
It is still not working... I mean, it just download the first file...
any idea?
Thank you!
You could try:
foreach line {CAPEMEND/FOR-UP.AT2 CAPEMEND/FOR000.AT2 CHICHI/CHY025-
W.AT2} {
exec {*}[auto_execok curl] -O http://peer.berkeley.edu/smcat/data/ath/$line
}
And see if that works...
I am thinking of rewriting all the script I made in Tcl using fully
bash syntax... I think it is more straightforward that way.
Thank you scottdware...
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
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"
}
}