The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Complex find grep or sed command sjburden Shell Programming and Scripting 3 05-31-2008 09:45 PM
complex grep command naamas03 Shell Programming and Scripting 0 11-21-2007 04:59 AM
Substitution of last command ghazi Shell Programming and Scripting 6 01-16-2005 07:06 PM
vi/vim : complex pattern substitution c444l UNIX for Dummies Questions & Answers 2 08-03-2004 10:04 AM
advanced/complex uses of the find command Perderabo Answers to Frequently Asked Questions 0 05-04-2004 01:13 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-21-2006
spopuri spopuri is offline
Registered User
  
 

Join Date: May 2006
Posts: 5
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!
  #2 (permalink)  
Old 05-21-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Incredible that it works at all. What shell are you using? Most shells will choke on an unmatched single quote.
  #3 (permalink)  
Old 05-21-2006
spopuri spopuri is offline
Registered User
  
 

Join Date: May 2006
Posts: 5
oops!

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!
  #4 (permalink)  
Old 05-24-2006
thestevew thestevew is offline
Registered User
  
 

Join Date: Mar 2006
Location: South Yorkshire, UK
Posts: 114
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)
Code:
$ ./z $a
$ z
Next run z with '$a' as a parameter and it prints "$a" (value not substituted because it's in single quotes)
Code:
$ ./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)
Code:
$ eval ./z '$a'
$ z
hope this helps
  #5 (permalink)  
Old 05-24-2006
Macer Macer is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 7
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?
  #6 (permalink)  
Old 05-24-2006
spopuri spopuri is offline
Registered User
  
 

Join Date: May 2006
Posts: 5
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;
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0