Help with Bash scripts
Hello all,
I have written a bash script which counts the number of lines in a given text file, and then chooses a random number and then reads the line number from the file basis that random number. The script looks like this: Code:
#!/bin/bash I tried adding as the last line in my script : Code:
xine ${LINE} HOWEVER, If I echo first: Code:
echo xine ${LINE} I really hope someone can help. |
Code:
awk 'BEGIN{ q="\047"} |
Quote:
It causes Xine to throw up an error box saying it cannot find the MRL. Plus, I don't quite understand all of what you have presented there. |
See http://www.linuxquestions.org/questi...l.....-309312/ for a similar problem. Basically it is possible that the MRL's that are being read in are not valid or they are no full pathnames.
Linux Archive |
Quote:
Code:
So the MRL is valid, I just don't know how to make a BASH script launch xine and pass a bunch of parameters that are stored in a $variable. An example of the parameters would be: --enqueue -S session=0,mrl=/home/user/kelly.mpg#volume:100 Now if I was to type into a terminal console: xine --enqueue -S session=0,mrl=/home/user/kelly.mpg#volume:100 it would work. I also know that when I run my BASH script, $LINE actually does look like: --enqueue -S session=0,mrl=/home/user/kelly.mpg#volume:100 but for some reason, if I try to use: xine ${LINE} The contents of $LINE are not treated as one bunch of parameters. I have a funny feeling that xine is trying to treat $LINE as just an MRL, which $LINE is more than just an MRL. I have also tried (with $LINE = /home/user/kelly.mpg#volume:100 (hence, just the valid url with a volume setting on the end which is allowed when using the enqueue option) xine --enqueue -S session=0,mrl=${LINE} |
Code:
LINE="--enqueue -S session=0,mrl=/usr/share/apps/k3b/extra/k3bphotosvcd.mpg#volume:100" |
Hi,
What happens if you try the following from the command line: Code:
LINE="--enqueue -S session=0,mrl=/home/user/kelly.mpg#volume:100" |
Quote:
Code:
xine "$LINE"#volume:10 /home/user/kelly.mpg which is kind of nearly what I want, only that: the line from the file MUST have a volume specifier at the end, so the line from the file has to look like this: /home/user/kelly.mpg#volume:10 So my next question would be, if I use sed to get read the line and print the line to $LINE. How could I strip the #volume:10 from it and make $VOL = #Volume:10 ? Gosh I hope this has made sense to someone, coz its difficult to describe. |
Another thing that came to mind (not a reply to post #8):
Have you tried the eval command? eval xine ${LINE} |
Quote:
xine "$LINE" seems to work with everything including file names that have spaces, so long as I dont have the #volume:10 on the end of the line. However, I need the volume argument on the end of the line, and I need to pass that as an arg to xine (some files are louder than others you see). So if I can just know how to separate the two pieces of information into two separate variables, I think it might do the trick. So close to what I need, I can smell it. |
Hi,
The # in the options line could be (is??) seen by bash as special when using ${LINE} (man bash for the details). That is why $LINE works (more or less) and ${LINE} does not. Maybe my eval option helps...... |
Quote:
/home/user/kelly.mpg#volume:100 and if I can use sed to put the above line into a variable called $TEMP and then somehow split $TEMP into two pieces, so that: $LINE = /home/user/kelly.mpg and introduce a new variable for volume, so that: $VOL = #volume:10 I reckon I can make that work by doing: xine --enqueue "$LINE"$VOL |
Hi,
Did you yake a look at post #9? You don't have to cut the original $LINE into pieces if that works..... |
Quote:
If the line in the file looks like this: /home/user/kelly.mpg#volume:100 Using either ${LINE} or $LINE behaves the same. It seems the #volume:100 really needs to be cut from the $LINE and put into another variable like $VOL. I just tested: Code:
$LINE="/home/user/kelly.mpg" So now I need to learn how to cut the line into two pieces. Edit: Oh wait, eval may work....one sec. |
It is still not clear from your answer if you tried the eval command ;)
Code:
LINE="--enqueue -S session=0,mrl=/home/user/kelly.mpg#volume:100" |
All times are GMT -5. The time now is 10:40 PM. |