Hi all,
Simple question: I’m using sox to analyze audio files but can’t get the return into a variable.
This works:
set bob to do shell script "ls"
As does this:
set bob to do shell script "sox ~/Music/test.aif -n stats >& ~/Music/tmp1.txt; cat ~/Music/tmp1.txt"
But I’d rather not have to use an external file.
This runs, but returns nothing to bob:
set bob to do shell script "sox ~/Music/test.aif -n stats"
Have you tried:
set bob to do shell script "echo sox ~/Music/test.aif -n stats"
Thanks, I knew it would be simple.
Except that it doesn’t do what I need. Maybe I wasn’t clear with my goal.
set bob to do shell script "echo sox ~/Music/test.aif -n stats"
This sets bob to sox ~/Music/test.aif -n stats. I need to set bob to the stderr that running the sox line returns:
Overall Left Right
DC offset -0.000002 -0.000002 -0.000002
Min level -0.084015 -0.084015 -0.083832
Max level 0.089966 0.079132 0.089966
Pk lev dB -20.92 -21.51 -20.92
RMS lev dB -43.97 -44.38 -43.60
RMS Pk dB -30.95 -32.19 -30.95
RMS Tr dB -87.67 -87.67 -86.96
Crest factor - 13.91 13.62
Flat factor 0.00 0.00 0.00
Pk count 2 2 2
Bit-depth 13/16 13/16 13/16
Num samples 56.1M
Length s 1271.471
Scale max 1.000000
Window s 0.050
V.K
February 24, 2012, 12:19am
#5
profcottle:
Except that it doesn’t do what I need. Maybe I wasn’t clear with my goal.
set bob to do shell script "sox ~/Music/test.aif -n stats"
This sets bob to sox ~/Music/test.aif -n stats. I need to set bob to the stderr that running the sox line returns:
Overall Left Right
DC offset -0.000002 -0.000002 -0.000002
Min level -0.084015 -0.084015 -0.083832
Max level 0.089966 0.079132 0.089966
Pk lev dB -20.92 -21.51 -20.92
RMS lev dB -43.97 -44.38 -43.60
RMS Pk dB -30.95 -32.19 -30.95
RMS Tr dB -87.67 -87.67 -86.96
Crest factor - 13.91 13.62
Flat factor 0.00 0.00 0.00
Pk count 2 2 2
Bit-depth 13/16 13/16 13/16
Num samples 56.1M
Length s 1271.471
Scale max 1.000000
Window s 0.050
just redirect stderr to stdout. try this
set bob to do shell script "echo sox ~/Music/test.aif -n stats 2>&1"
Still doesn’t return what I need. Running this line simply returns the line: “sox /Users/u0316714/Music/test.aif -n stats”, not the data that it produces.
V.K
February 24, 2012, 6:07am
#7
sorry, bad copy and paste on my part. I thought I removed “echo” from there. It should be like this
set bob to do shell script "sox ~/Music/test.aif -n stats 2>&1"