Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

whats wrong with this code?

#!/bin/bash
ARCH=$(uname -m)
if ["$ARCH" = "i686"]; then
 zenity --info --title="Architechture Checker" --text="Your Architechture is 32-Bit"
if ["$ARCH" = "x86_64"];then
 zenity --info --title="Architechture Checker" --text= "Your Architechture is 64-Bit"
share|improve this question
add comment

2 Answers

up vote 7 down vote accepted
  1. No matching "fi" for the "if"s

  2. You need to put whitespace around "[" and "]"

  3. Space after "--text=" makes the parameter get lost.

Working version:

#!/bin/bash
ARCH=$(uname -m)
if [ "$ARCH" = "i686" ]; then
 zenity --info --title="Architechture Checker" --text="Your Architechture is 32-Bit"
fi
if [ "$ARCH" = "x86_64" ]; then
 zenity --info --title="Architechture Checker" --text="Your Architechture is 64-Bit"
fi
share|improve this answer
add comment

Or, using case instead (and also a function to shorten it a bit).

#!/bin/bash

zinfo() { zenity --info --title="Architecture Checker" --text="$1"; }

case $(uname -m) in
  i686) zinfo "Your architecture is 32-bit" ;;
  x86_64) zinfo "Your architecture is 64-bit" ;;
  *) zinfo "Your architecture is unknown to me" ;;
esac
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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