LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Taking Linux in college and am currently stumped on a project (https://www.linuxquestions.org/questions/linux-newbie-8/taking-linux-in-college-and-am-currently-stumped-on-a-project-4175542551/)

rykenknight04 05-13-2015 11:14 PM

Taking Linux in college and am currently stumped on a project
 
Currently taking my first linux course in college and am stuck on a project...details here: https://aacc.instructure.com/courses...item_id=614603

So far this is the code I have come up with but get an error on the 42nd line where it says done. I am not an expert by any means but would like to not struggle and finish this project. Below is my code...any input welcome.

#!/bin/bash
#blinker
#creates a bi-stable process that displays ON and OFF
touch .running
clear
while [ -f .running ]
do
count=0
while [ -f .running ]
do
count=$((count+1))
if [ $count -gt 4 ]
then
break
fi
echo "Green"
sleep 4
done
count=0
while [ -f .running ]
do
count=$((count+1))
if [ $count -gt 4 ]
then
break
fi
echo "red"
sleep 4
count=0
while [ -f .running ]
do
count=$((count+1))
if [ $count -gt 2 ]
then
break
fi
echo "green"
sleep 2
count=0
while [ -f .running ]
do
done
done

ardvark71 05-13-2015 11:20 PM

Hi...

Welcome to the forum :)

Just as a heads up, clicking on your link leads to a login page only, so there's no way to view your information. ;)

Regards...

alan99 05-14-2015 12:20 AM

I believe it against the rules of this forum (see for details http://www.linuxquestions.org/linux/rules.html ) and probably the ethics of your school. If someone just 'gave' you an answer it would be considered cheating and you wouldn't really learn how to solve problems and troubleshoot code, would you? Also, If you want somebody to look at the error, print line numbers with your statements, it is hard for someone reading your post to have to count the number of lines to find out where the error is.

SAbhi 05-14-2015 03:38 AM

All i can say is you are going a wrong way, as said above we cant do your homework. You have to take the trouble to solve your own problem.

millgates 05-14-2015 04:55 AM

Hi,
My first advice would be to format your code. If you use proper indentation, you will immediately see where the flaws in the structure of your code are.
Also, if you post your code here, put it within the [code] [/code] tags so that the indentation is preserved.

JeremyBoden 05-15-2015 06:52 AM

What is the point of the first 3 lines?
Code:

touch .running
clear
while [ -f .running ]
....


jtbinuya 05-15-2015 08:34 AM

running in debug mode would probably give more hints to what your error is pointing to. Have you tried adding set -x at the start of the script just after the shell initialization ( after the 1st three commented lines)


All times are GMT -5. The time now is 05:40 AM.