Re: [GTALUG] Bash Problem

2017-01-07 Thread Mauro Souza via talk
Quotes. I second to that.

To see how the script are interpreting things, run bash -vx script.sh.

Or install and use bashdb (bash debugger). It's very, very useful.

On Jan 7, 2017 22:38, "Michael Galea via talk"  wrote:

> On 01/07/17 19:25, Stephen via talk wrote:
>
>> I am new to Bash scripts.
>>
>> I am trying to create a script to use avconv to convert mkv files to mp4
>> file.
>>
>> Run one at a time the command runs fine.
>>
>> When I execute this script I get an error about an unknown parameter. I
>> am guessing that the expansion with the filename variables is failing.
>>
>> Can someone help me correct?
>>
>> Thank you!
>>
>> #!/bin/bash
>> # Usage: convert file to mp4
>> shopt -s nullglob
>> ext='.mp4'
>> for f in *.mkv
>> do
>>base=$(basename $f .mkv)
>>nFname=$base".mp4"
>>echo $nFname
>>avconv "-i $f -c:v libx264 -c:a copy $nFname"
>> done
>>
>>
>>
> Shouldn't you be quoting $f and $nFname separately, e.g.
>  avconv -i "$f" -c:v libx264 -c:a copy "$nFname"
> otherwise filenames with spaces will see -i catch only part of the
> filename.
>
> Try adding echo in front of the avconv command and see what would be
> executed from within the script.
>
> --
> Michael Galea
> ---
> Talk Mailing List
> talk@gtalug.org
> https://gtalug.org/mailman/listinfo/talk
>
---
Talk Mailing List
talk@gtalug.org
https://gtalug.org/mailman/listinfo/talk


Re: [GTALUG] Bash Problem

2017-01-07 Thread Michael Galea via talk

On 01/07/17 19:25, Stephen via talk wrote:

I am new to Bash scripts.

I am trying to create a script to use avconv to convert mkv files to mp4
file.

Run one at a time the command runs fine.

When I execute this script I get an error about an unknown parameter. I
am guessing that the expansion with the filename variables is failing.

Can someone help me correct?

Thank you!

#!/bin/bash
# Usage: convert file to mp4
shopt -s nullglob
ext='.mp4'
for f in *.mkv
do
   base=$(basename $f .mkv)
   nFname=$base".mp4"
   echo $nFname
   avconv "-i $f -c:v libx264 -c:a copy $nFname"
done




Shouldn't you be quoting $f and $nFname separately, e.g.
 avconv -i "$f" -c:v libx264 -c:a copy "$nFname"
otherwise filenames with spaces will see -i catch only part of the filename.

Try adding echo in front of the avconv command and see what would be 
executed from within the script.


--
Michael Galea
---
Talk Mailing List
talk@gtalug.org
https://gtalug.org/mailman/listinfo/talk


[GTALUG] Bash Problem

2017-01-07 Thread Stephen via talk

I am new to Bash scripts.

I am trying to create a script to use avconv to convert mkv files to mp4 
file.


Run one at a time the command runs fine.

When I execute this script I get an error about an unknown parameter. I 
am guessing that the expansion with the filename variables is failing.


Can someone help me correct?

Thank you!

#!/bin/bash
# Usage: convert file to mp4
shopt -s nullglob
ext='.mp4'
for f in *.mkv
do
   base=$(basename $f .mkv)
   nFname=$base".mp4"
   echo $nFname
   avconv "-i $f -c:v libx264 -c:a copy $nFname"
done


--
Stephen
---
Talk Mailing List
talk@gtalug.org
https://gtalug.org/mailman/listinfo/talk