PDA

View Full Version : Bash question



oomar
August 12th, 2009, 04:23 AM
Im just starting to learn how to program bash and recently just wrote a completely random script and cant seem to figure out why its coming up with errors. Ive changed it several times and probably screwed it up more but please take a look and see if you can spot my problems.



#!/bin/bash
$var = "thing"
while var == "thing"; do
echo "test"
read testvar
if $testvar == "exit"; then
exit 0
fi
echo "You wrote " + $testvar
done
sleep 10

just a random program.

enz1m3
August 13th, 2009, 10:00 AM
Your variable declaration is badly done, aswell as the loop syntax, if syntax, etc.

Check, this is tested and working.



#!/bin/bash
thevar="thing"
while [ $thevar == "thing" ]; do
echo "test"
read testvar
if [ $testvar == "exit" ]; then
exit 0
fi
echo "You wrote " + $testvar
done
sleep 10