I have a script which assigns the output of a shell command to a string, for later comparison.
The command typically outputs either "Idle" or
"Uploading 1 file (102.8 KB/sec, 1 min left)"
I use a test:
while test $status != 'Idle'
However, when the string is not equal to 'Idle' it crashes, possibly because of the unusual characters such as / and ( etc. in the alternative output.
Is it possible to compare or even prepare the string before comparison so that my script doesn't crash? Or is shell scripting limited in this way, in which case I should be using a different language?
Here is the script in case it makes things clearer. It's purpose is to start dropbox, allow it's running while it is performing any action, but exiting if everything is already up to date.
#! /bin/sh
dropbox start
status=$(dropbox status)
while test $status != 'Idle'
do
echo "Working"
status=$(dropbox status)
done
echo "\nIdle again.. exiting"
dropbox stop