What's wrong with this Zenity code?

Tags:

Answer: 1

17 hours ago

What’s 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"
Added by: Frederic Koch

Answer: 2

2 hours ago

  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
Added by: Toney Bode III

Answer: 3

17 hours ago

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

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9