![]() |
help with execute mulitple shell script within shell script
I am trying to get a result of one executable to be input of other executable. I found one on the internet, and it works great.
However, when put it in the shell script, it does not work.. Can someone help here is the command. $ sox infile outfile vol `sox infile -n stat -v 2>&1` In my shell script, i wrote cm=`sox infile outfile vol `sox infile -n stat -v 2>&1`` also try cm=`sox infile outfile vol $(sox infile -n stat -v 2>&1)` None of this work. can someone help? |
What you doing is placing the output of the second sox command onto the command line of the first sox command. This isn't what you want, and won't work.
Under the Filenames section of the man page, sox shows filenames can be: Quote:
Code:
sox infile - vol | sox - -n stat -v |
You could deivide your line into two:
Code:
vol=`sox infile -n stat -v 2>&1` |
Vit77's response makes me think I may have misinterpreted the request.
If the OP is trying to perform nested command substitution, that works just fine: Code:
$ set -vPerhaps the OP can be more specific than "None of this work". |
ufmale said that the first way (commant-line) works great.
The first sox calculates and returns the maximum volume of an audio file, and this value is substituted as an argument the first sox. I suspect the main fail reason of the last OP's script might be in -v 2>&1 structure. -v option requires an argument, so 2 should be this argument, whereas 2> could be interpreted as stderr. If so, the decision is a space char between 2 and >. |
The 2>&1 is redirecting STDERR to the STDIN stream. The shell parses this as a single unit. If 2 were an option value to -v, that would leave >&1. This would be equivalent to >1 2>&1, which isn't likely desired.
The first form posted: Code:
cm=`sox infile outfile vol `sox infile -n stat -v 2>&1``cm=`sox infile outfile vol ` sox infile -n stat -v 2>&1`` and this is equivalent to: Code:
$ cm=a b cCode:
$ set -x |
Thank you Mr. C. and Vit77. Now I am understanding more about nesting issue.
It now work great using the suggestion from Vit77. Quote:
|
| All times are GMT -5. The time now is 08:32 PM. |