bash scripting help

have this code but when i run it i get this error

 ./pulse: line 2: [: pulseaudio --check ; echo 0: integer expression expected 

and here is the code

#!/bin/bash
if [ "pulseaudio --check ; echo $?" -eq "0" ];
then
   pulseaudio -k;

fi

what am i doing wrong

thanks
Adam

You are comparing the string "pulseaudio --check ; echo $?" with "0".

From the test man page:

       INTEGER1 -eq INTEGER2
              INTEGER1 is equal to INTEGER2
#!/bin/bash
pulseaudio --check

if [ $? -eq 0 ];
then
   pulseaudio -k;
fi

or

#!/bin/bash
if pulseaudio --check
then
   pulseaudio -k;
fi

thanks that worked like a dream

lastly, is there a way to check is skype is runnung and if so kill it

i can do a

 killall skype 

but if skype is not running it retuns that there is no process running, which i do not want

If "killall skype" works, and you only want to get rid of the message, try adding 2> /dev/null to the command, or the -q option if you're version has that option.

killall skpye 2>/dev/null 

thanks guys