Shell script problem

Patton Echols p.echols at comcast.net
Tue Mar 2 06:48:02 UTC 2010


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.  For ease of 
reading the  files are named three.avi, four.avi, and five.avi  (very 
original)  The output is pasted below my comments.

Some things I noticed.

First, the declare command at the beginning of the script throws a "not 
found"  Is that an error?

Second, the script / shell is able to find the files because it 
successfully finds them to verify type.

Third, I get the same "not found" error as vijay on each avi file name.  
But from the above, I think that there is something wrong with assigning 
the file name to the array.  THAT is what is "not found" not the file 
itself.

I do not know enough about assigning array variables to troubleshoot.  I 
am going to do a little searching after posting this, but since my "self 
education" comes in fits and starts, thought others might want to take a 
look sooner.

=========== Command Output =======

patton at Mycroft:~/Videos/motion$ sh -x ./join_files.sh
+ SUPPORTED_FILE_TYPE=avi
+ OUTPUT_FILE_NAME=joined-output.avi
+ SLEEP_INTERVAL=3
+ declare -a FILES
./join_files.sh: 1: declare: not found
+ echo Preparing to join avi files.
Preparing to join avi files.
+ need_more=yes
+ file_count=0
+ [ yes = yes ]
+ echo -n Enter file name >
Enter file name > + read filename
three.avi
+ echo You entered: three.avi .... Verifing file integrity.
You entered: three.avi .... Verifing file integrity.
+ [ -f three.avi ]
+ echo three.avi
+ awk -F . {if (NF>1) {print $NF}}
+ file_ext=avi
+ [ avi != avi ]
+ echo file is okay
file is okay
+ FILES[0]=three.avi
./join_files.sh: 1: FILES[0]=three.avi: not found
+ echo added to array
added to array
+ file_count=1
+ echo Do you want to add more files. Please enter yes or no
Do you want to add more files. Please enter yes or no
+ read need_more
yes
+ [ yes != no ]
+ [ yes != yes ]
+ [ yes = yes ]
+ echo -n Enter file name >
Enter file name > + read filename
four.avi
+ echo You entered: four.avi .... Verifing file integrity.
You entered: four.avi .... Verifing file integrity.
+ [ -f four.avi ]
+ echo four.avi
+ awk -F . {if (NF>1) {print $NF}}
+ file_ext=avi
+ [ avi != avi ]
+ echo file is okay
file is okay
+ FILES[1]=four.avi
./join_files.sh: 1: FILES[1]=four.avi: not found
+ echo added to array
added to array
+ file_count=2
+ echo Do you want to add more files. Please enter yes or no
Do you want to add more files. Please enter yes or no
+ read need_more
yes
+ [ yes != no ]
+ [ yes != yes ]
+ [ yes = yes ]
+ echo -n Enter file name >
Enter file name > + read filename
five.avi
+ echo You entered: five.avi .... Verifing file integrity.
You entered: five.avi .... Verifing file integrity.
+ [ -f five.avi ]
+ echo five.avi
+ awk -F . {if (NF>1) {print $NF}}
+ file_ext=avi
+ [ avi != avi ]
+ echo file is okay
file is okay
+ FILES[2]=five.avi
./join_files.sh: 1: FILES[2]=five.avi: not found
+ echo added to array
added to array
+ file_count=3
+ echo Do you want to add more files. Please enter yes or no
Do you want to add more files. Please enter yes or no
+ read need_more
no
+ [ no != no ]
+ [ no = yes ]
+ sleepBy
+ sleep 3
+ echo preparing join command
preparing join command
+ joinCommand=mencoder -oac copy -ovc copy -o
+ joinCommand=mencoder -oac copy -ovc copy -o joined-output.avi
+ echo Going to execute command mencoder -oac copy -ovc copy -o 
joined-output.avi
Going to execute command mencoder -oac copy -ovc copy -o joined-output.avi
+ echo size = 0
size = 0
+ echo Going to execute command mencoder -oac copy -ovc copy -o 
joined-output.avi
Going to execute command mencoder -oac copy -ovc copy -o joined-output.avi





More information about the ubuntu-users mailing list