0

Hello I am trying to run a loop and get the details of a project. I have these projects in my work space. How do I loop over the SQL code?

#!/bin/bash


    workspace=$(sudo locate -r '/workspace$')
    cd $workspace
    echo "" > ~/Desktop/workspace.txt
    for projectName in `ls -d *`;
    do
        echo $projectName >> ~/Desktop/workspace.txt
    done

    cat workspace.txt | while read Name
    sqlplus $1/$2 <<ENDOFSQL > ~/Desktop/$Name.txt
    DESC PROJECTS;
    SELECT ID_NAME, VALUE FROM PROJECTS WHERE ID_NAME='%${Name}%';
    exit;
    ENDOFSQL

    echo "Testing"

When I run it, I get the error

./sql_parameters.sh: line 24: syntax error: unexpected end of file
2

two things:

while should be in this form

while condition; do
    your code from while
done

also, make sure ENDOFSQL is from new line and there are no spaces between.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.