[SWLUG] another bash question

bascule asura at theexcession.co.uk
Sun May 4 14:32:51 UTC 2003


again something i'd like to understand

the following script produces an infinite
run:
#!/bin/bash
#
#lines=$(cat args_list|wc -l)
lines=6
#
flag=1
#
#while [ "$flag" -le "$lines" ]
while [ "$flag" -le 6 ]
#
#aflag=$lines - $flag"
aflag="6 - $flag"
#
artist=$(head --lines=6 args_list |tail --lines=$aflag|gawk -F " %% " '{print 
$1}' )
#
album=$(head --lines=6 args_list |tail --lines=$aflag|gawk -F " %% " '{print 
$2}' )
#
track=$(head --lines=6 args_list |tail --lines=$aflag|gawk -F " %% " '{print 
$3}' )
#
song=$(head --lines=6 args_list |tail --lines=$aflag|gawk -F " %% " '{print 
$4}' )
#
file=$(head --lines=6 args_list |tail --lines=$aflag|gawk -F " %% " '{print 
$5}' )
#
	do id3v2  -a$artist -A$album -T$track -t$song $file
	flag=$((flag+1))
done

-----
running the sxcript gives:
[bascule at mycroft tmp]$ ../scripts/bmp3/bmp3tag2
tail: 1: No such file or directory
tail: 1: No such file or directory
tail: 1: No such file or directory
tail: 1: No such file or directory
tail: 1: No such file or directoryflag=$((flag+1))
tail: 2: No such file or directory
tail: 2: No such file or directory
tail: 2: No such file or directory
tail: 2: No such file or directory
tail: 2: No such file or directory
tail: 3: No such file or directory

and the number just keeps getting bigger!
if i comment everything except the 'while' and the flag=$((flag+1)) and stick 
in a 'do uname' or something it's clear the while construction is correct cos 
i get 6 iterationsd of the same thing

so, any ideas, is it the assigning of numerical values to variables, maybe 
using the 'flag' as a variable in the inner statements?

bascule

args_list looks like:
[bascule at mycroft tmp]$ cat args_list
"Barenaked Ladies" %% "Born On A Pirate Ship" %% "15" %% "If I Had $1000000" 
%% "15_If I Had 1000000.mp3"
"Barenaked Ladies" %% "Stunt" %% "1" %% "One Week" %% "01_One Week.mp3"
"Barenaked Ladies" %% "Stunt" %% "3" %% "Light Up My Room" %% "03_Light Up My 
Room.mp3"
"Barenaked Ladies" %% "Stunt" %% "4" %% "I'll Be That Girl" %% "04_I'll Be 
That Girl.mp3"
"Barenaked Ladies" %% "Stunt" %% "7" %% "Call and Answer" %% "07_Call and 
Answer.mp3"
"Barenaked Ladies" %% "Stunt" %% "13" %% "When You Dream" %% "13_When You 
Dream.mp3"
[bascule at mycroft tmp]$
-- 
"Oh no, not again." 

-- A bowl of petunias on it's way to certain death. 





More information about the Swlug mailing list