complex command substitution

hi,
I have to execute this line below from within a shell script; simply backquoting it is not doing the trick; it is mangling up all the options; but when i type it out on a command line, it executes cleanly. Please help me in getting this right;

$ vlc -I dummy --sout='#transcode{vcodec=mp4v, acodec=mp4a}:std{access=file, mux=mp4, url=temp.mp4} file.avi

As you can see, the syntax of the option specification for VLC includes many complex tokens; Can you guide me to get it working from within backquotes?

Thanks!

Incredible that it works at all. What shell are you using? Most shells will choke on an unmatched single quote.

ok, there is no unmatched single quote; thanks a lot for pointing out; this is the corrected command line:

$ vlc -I dummy --sout='#transcode{vcodec=mp4v,acodec=mp4a}:std{access=file,mux=mp4,url=temp.mp4} ' file.avi

I got this partially working by simply writing the line in the shell script (without an backquotes). The problem is my temp.mp4 and file.avi are actually inside variables $T and $F; something like this works:

#!/bin/sh

#do some string manipulation to determine values of $T and $F

vlc -I dummy --sout='#transcode{vcodec=mp4v,acodec=mp4a}:std{access=file,mux=mp4,url=temp.mp4} ' "$F"

but if I replace $T for temp.mp4, it wont work anymore; I dont care about the return value of this command, so I dont need backquotes;

So, the problem has boiled down to - how do I make the shell interpret the $ variable inside those single quotes?

Thanks!

What you need to do is pre-process the command line within the single quotes, performing variable substution. I don't know about your application, so here is a trivial example which should make it clear.

There is a one line script called z containing the line "print $1"
There is a variable within the current shell with the value "z" (a=z)
First run z with $a as a parameter and it prints "z" (value substituted)

$ ./z $a
$ z

Next run z with '$a' as a parameter and it prints "$a" (value not substituted because it's in single quotes)

$ ./z '$a'
$ z

Finally, run with eval and value is substuted even though in quotes (substitution is actually done as a separate step before command is executed)

$ eval ./z '$a'
$ z

hope this helps

Could you not just unquote at the point you need the variable interpolation:

vlc -I dummy --sout='#transcode{vcodec=mp4v,acodec=mp4a}:std{access=file,mux=mp4,url='$T'} ' "$F"

Does that work?

hi all, thanks a lot, I solved the problem with some generous usage of quotes..
vlc -I dummy --sout=""#transcode{vcodec=mp4v,acodec=mp4a}:std{access=file,mux=mp4,url=$T} "" $F

did the trick; the problem was that I needed some kind of quotes after --sout= as part of the commad line syntax;