Shell script problem

Patton Echols p.echols at comcast.net
Tue Mar 2 08:37:43 UTC 2010


On 03/01/2010 11:20 PM, Vijay Shanker Dubey wrote:
> please read inline
>
> Regards,
> Vijay Shanker Dubey
>
>
>
> On Tue, Mar 2, 2010 at 12:18 PM, Patton Echols <p.echols at comcast.net 
> <mailto:p.echols at comcast.net>> wrote:
>
>     On 03/01/2010 08:19 AM, James Kaufman wrote:
>     > On 3/1/2010 8:13 AM, Vijay Shanker Dubey wrote:
>     >
>     > Perhaps I am wrong. One thing you can try is to run your shell
>     command
>     > like this:
>     >
>     > sh -x ./join_files.sh
>     >
>     >
>
>
>     Sticking my nose in.  I had some small avi files laying around and ran
>     the script against them with the sh -x switch as suggested.  (Tried it
>     with both #!/bin/sh and #!/bin/bash with the same results.  <SNIP>
>
>
> #!/bin/sh
>
> and change it to
>
> #!/bin/bash

Yes, I had seen that, but also was trying to produce the debug output.  
Rookie mistake! 

If you call a script with sh -x ./<scriptname>

It will be used with the "sh" interpreter instead of "bash" regardless 
of the first line of the file!  If you want to do the same with bash, 
then it is $bash -x ./myscript.sh

Thanks Nils for the pointers too.

By the way, Vijay.  To get your scrip to actually join files, you do not 
need the last fiddly loop.  Take it out and put in this:

joinCommand="mencoder -oac copy -ovc copy -o"

#add output file name
joinCommand="$joinCommand $OUTPUT_FILE_NAME"

# append files
joinCommand="$joinCommand ${FILES[@]}"

# Tell us what you are doing
echo "Going to execute command $joinCommand"

#do it
$joinCommand


=============

Obviously this could all be done in one step:
joinCommand="$joinCommand $OUTPUT_FILE_NAME ${FILES[@]}"

Interesting script.  Thanks for the "lesson."

--PE





More information about the ubuntu-users mailing list