Register
It is currently Thu Apr 17, 2014 6:30 am

syntax


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Wed Feb 02, 2011 4:31 pm   

Joined: Wed Feb 02, 2011 4:28 pm
Posts: 1
Hi, I just started playing with this, but I am not sure what my syntax error is, can anyone please check,
Code:
        DIR0=$CURDIR
        DIR=/usb${DIR0}
        echo "<table>"
        echo "$(ls -lL "${DIR}")" | while read LINE
        do
                #FILENAME=$(echo "$LINE" | cut -c 57-)
                FILENAME=${LINE:56}
                #FILE_PROPERTIES=$(echo "$LINE" | cut -c -56)
                FILE_PROPERTIES=${LINE:0:56}
                #ISDIR=$(echo "$LINE" | cut -c 1)
                ISDIR=${LINE:0:1}
               
                #ext = ${FILENAME##*.}
                echo $ext
                if [ $ext == ".jpg" || $ext == ".jpeg" ] ; then
                DES = "Image"
                elif [ $ext == ".gif" ] ; then
                DES = "Image"
                elif [ $ext == ".bmp" ] ; then
                DES = "Image"
                elif [ $ext == ".png" ] ; then
                DES = "Image"
                else DES = "Unknown"
                fi
               
                if [ "$ISDIR" = "d" ] ; then dell = "<a onClick=\"if (ConfirmDeleteDir('${DIR0}/${FILENAME}')) {del.deldir.value='${DIR}/${FILENAME}';del.submit();}\">" ; open = "<a onClick=\"setValue('${DIR0}/${FILENAME}');folderlist.submit();\">"
                else dell = "<a onClick=\"if (ConfirmDeleteFile('${DIR0}/${FILENAME}')) {del.delfilename.value='${DIR}/${FILENAME}';del.submit();}\">" ; open = "<a onClick=\"if (ConfirmDownload('${DIR}/${FILENAME}')) {setValue('${DIR}/${FILENAME}');downloadfile.submit();}\">"
                fi

And by any chance, how would i turn on the error reporting? so it is easier to track?
Thanks :&


Top
 Profile  
 PostPosted: Wed Feb 02, 2011 5:20 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 511
Hi,

- write all variable names in lower case
- quote assignments
- don't parse ls output; instead, use globbing with a for loop
- == and || don't exist inside [ ]
- use case..in..esac, instead of if..then..elif...
- assignments don't want spaces around =
- do needs done

set -x : Print commands and their arguments as they are executed.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP