jazzman1 Posted November 17, 2012 Share Posted November 17, 2012 Hey friends, I'm trying to run a video file from mms (microsoft media server) into a linux terminal , but I've got a syntax bash error. How to escape parenthesis and maybe encoding empty spaces? Example : mplayer mms://vod.bgtelevizia.com/vod/onlineBTV-HQ/[bTV] 2012.11.18 -Sunday- (00-00).wmv ERROR: bash: syntax error near unexpected token `(' Example 2 works without any problems: mplayer mms://v3.bgtelevizia.com/onlinebtv?token=4d377bcabbec99de204f68b5dbbba2fd Thank you in advance! Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/ Share on other sites More sharing options...
Pikachu2000 Posted November 17, 2012 Share Posted November 17, 2012 The parentheses need to be escaped with backslashes, most likely. Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1393301 Share on other sites More sharing options...
jazzman1 Posted November 18, 2012 Author Share Posted November 18, 2012 (edited) I know that Pika, but the syntax error still appears. Ops, new error appears: ERROR: Error parsing option on the command line: -Sunday- Edited November 18, 2012 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1393302 Share on other sites More sharing options...
Christian F. Posted November 18, 2012 Share Posted November 18, 2012 (edited) The spaces, dashes, and a few other characters, needs to be escaped as well. If the command is generated automatically by a script, use escapeshellarg () on the filename to prevent errors like these from happening. Edited November 18, 2012 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1393308 Share on other sites More sharing options...
jazzman1 Posted November 18, 2012 Author Share Posted November 18, 2012 Can you give me a simple example reference to the script above? Thank you buddy Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1393309 Share on other sites More sharing options...
Christian F. Posted November 18, 2012 Share Posted November 18, 2012 $cmd = 'mplayer '.escapeshellarg ($url); Or were you thinking of something else..? Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1393311 Share on other sites More sharing options...
jazzman1 Posted November 18, 2012 Author Share Posted November 18, 2012 Christian, forget about php. This is only a bash script dumping the file from a mms remote server. It's going to be something like this: mplayer -dumpstream -dumpfile 2012.11.18 -Sunday- (00-00).wmv mms://vod.bgtelevizia.com/vod/onlineBTV-HQ/[bTV] 2012.11.18 -Sunday- (00-00).wmv Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1393313 Share on other sites More sharing options...
Pikachu2000 Posted November 18, 2012 Share Posted November 18, 2012 (edited) Quoting the string gets rid of any bash errors for me, but I don't have mplayer installed, and I'm on OS X. Probably worth playing around with, though. mplayer -dumpstream -dumpfile "2012.11.18 -Sunday- (00-00).wmv mms://vod.bgtelevizia.com/vod/onlineBTV-HQ/[bTV] 2012.11.18 -Sunday- (00-00).wmv" Edited November 18, 2012 by Pikachu2000 Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1393315 Share on other sites More sharing options...
jazzman1 Posted November 18, 2012 Author Share Posted November 18, 2012 Hm.... there is no error message, but still nothing happened. I'll continue digging up, maybe the problem now is from a remote one. Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1393317 Share on other sites More sharing options...
DavidAM Posted November 18, 2012 Share Posted November 18, 2012 You should try using single-quotes. Parameters are "expanded" inside double-quotes but not inside single-quotes -- Similar to PHP string quoting and variables. Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1393345 Share on other sites More sharing options...
jazzman1 Posted December 20, 2012 Author Share Posted December 20, 2012 (edited) Wow..... I've got it guys, linux is amazing and the people of that community, too I needed to add that string to mplayer's config file. For example: vim ~/.mplayer/config // add this prefer-ipv4=yes If you want it, you can try using my token to this particular streaming file, to check what's going on. mplayer -dumpstream -dumpfile '2012.12.19 -Wednesday- (18-00).wmv' 'mms://67.159.54.219/vod/onlineBTV/[bTV] 2012.12.19 -Wednesday- (18-00).wmv?token=aea1884748fa97f6672c089db7eb92e0' Now the question is, how to login via BASH to get the generating token to this particular account? I'm thinking myself about CURL ? Edited December 20, 2012 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1400524 Share on other sites More sharing options...
jazzman1 Posted December 23, 2012 Author Share Posted December 23, 2012 Hi guys, this thread is already solved! If someone wants to see what's going on, please send me PM to provide her/him a real userName and password ( Christian, I was thinking about you ) Thanks for taking the time to help me about this. #!/bin/bash NAME='your Name' PASS='your Password' HIDDEN=`date '+%s'` TIME=`date '+%Y%m%d'` curl --cookie-jar cjar --output /dev/null 'http://www.djtacho.com/member/plugins/protect/new_rewrite/login.php?v=-any&url=/members/' curl --cookie cjar --cookie-jar cjar --data 'amember_login='${NAME} --data 'amember_pass='${PASS} --data 'login_attempt_id='${HIDDEN} --location \ 'http://www.djtacho.com/member/plugins/protect/new_rewrite/login.php?v=-any&url=/members/' curl --verbose --cookie cjar --output ~/televizia.html 'http://www.djtacho.com/members/televizia.php' grep -o 'mms://video.djtacho.com/onlineBTV\-hq?token=[a-zA-Z0-9]*' televizia.html > tvFile.txt while read line; do mplayer -dumpstream -dumpfile ${TIME}.wmv $line # or whaterver you want to do with the $line variable sleep 300 done < tvFile.txt Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1400966 Share on other sites More sharing options...
Christian F. Posted December 23, 2012 Share Posted December 23, 2012 Glad to hear that you got it sorted out. I was just looking to see what code you already had, so that I could see what was wrong with it. But, since you already fixed it, there's nothing more for me to add. Quote Link to comment https://forums.phpfreaks.com/topic/270844-bash-syntax-error/#findComment-1400981 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.