Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Bash script won't run because hardware won't produce display


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Bash script won't run because hardware won't produce display

Can anyone offer any advice on how to modify the script below to work on a new system we have, that has no graphics capability? We admin the system through a serial RAS device. I've tried running the below script through the RAS and through an ssh -X session. It failed with something like "GTK unable to produce display". Python scripts however do produce menus and such on screen and I don't understand the difference. Any help/advice is greatly appreciated. Thank you.

This script is supposed to produce a text box on screen, that our installers enter a 4 digit code on. That code is checked for validity and if it is, the script completes. I have several other scripts just like this one, all with the same problem. Is is zenity????

Code:
#!/bin/bash

VER=`zenity --entry --text "Please enter the ACG pgm number:" --title "Version Entry"`

if [ -z "$VER" ]; then
	echo "ERROR: Version entry was not provided."
	exit 1
fi

IS_OK=`echo $VER | egrep "[0-9]{4}"`

if [ -z "$IS_OK" ]; then
	zenity --question --text "'$VER' does not appear to be a
valid version string.

Continue anyway?"
	if [ $? -ne 0 ]; then
		echo "ERROR: Invalid version entry."
		exit 1
	fi
fi

echo $VER > /etc/acg-oe-pgm

# 2  
Hi,

Yes, the issue here is most likely to be zenity, as you say. zenity is a utility for displaying dialog boxes in an X Windows graphical environment. If you're running this server headless (i.e. you have no monitor connected and are interacting with it purely over a serial link) then zenity isn't going to work. Your best bet would be to switch out zenity for another text-only utility such as dialog, which can display interactive full-screen text mode dialog boxes to query the user for information. That should work in any terminal session regardless of whether the script was being started in an xterm running in X11, on a text mode virtual console, or over a serial link. If you check out the man page for dialog it'll give you a description of how it works, but it shouldn't be too hard to re-work your script to use one rather than the other.
These 2 Users Gave Thanks to drysdalk For This Post:
# 3  
The following shell script emulates zenity on a console device.
Code:
#!/bin/bash

if [ -n "$DISPLAY" ] && xdpyinfo >/dev/null 2>&1
then
  graphics=1
else
  graphics=
fi

# a wrapper for zenity that does console I/O if no graphics
dialog(){
  if [ -n "$graphics" ]
  then
    zenity "$@"
    return
  fi
  do_text= text= do_yes_exit=
  for arg
  do
    if [ -n "$do_text" ]
    then
      text=$arg
      do_text=
    else
      case $arg in
      (--text) do_text=1;;
      (--question) do_yes_exit=1;;
      esac
    fi
  done
  read -p "$text: " input
  if [ -z "$do_yes_exit" ]
  then
    echo "$input"
    return
  fi
  case $input in
  ([Yy]*) return 0;;
  esac
  return 1
}

VER=$(
  dialog --entry --text "Please enter the ACG pgm number:" --title "Version Entry"
)

if [ -z "$VER" ]; then
  echo "ERROR: Version entry was not provided."
  exit 1
fi

case $VER in
([0-9][0-9][0-9][0-9])
;;
(*)
  dialog --question --text "'$VER' does not appear to be a
valid version string.

Continue anyway?"
;;
esac

if [ $? -ne 0 ]
then
  echo "ERROR: Invalid version entry."
  exit 1
fi

echo "$VER" > /etc/acg-oe-pgm

This User Gave Thanks to MadeInGermany For This Post:
# 4  
Thanks to all

Just wanted to take a moment and thank you all for your help. It's greatly appreciated. Cheers~
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
bash script won't execute (Mac)
compulsiveguile
I can't get any bash scripts to run in Terminal (Mac - Snow Leopard). I have the following super-simple script, and I can't get it to execute despite having the correct permissions (I think). #!/bin/bash echo "WORK... PLEASE?!" I named the file 'testScript.sh', and I added execution...... Shell Programming and Scripting
6
Shell Programming and Scripting
tip: Simple script won't run in cygwin - vim editor involved
oxysep
I ran into this issue and thanks to various postings in various forums, was able to figure out the solution but didn't see one posting that laid the whole issue out cleanly. So thought the following might help others ... ------------------------------------------------------------------------...... UNIX for Dummies Questions & Answers
2
UNIX for Dummies Questions & Answers
won't mount /usr...won't boot fully
bbird
Hello: NOOB here. I attempted to use smit mkcd. Failed on first attempt, not enough space. 2nd attempt tried to place iso on /usr, not enough space there. Cleanup ran for about 5 minutes after aborting. Now AIX won't boot. LCD display on 7029-6E3 says: 0517 MOUNT /USR. Attempted to boot from CD...... AIX
11
AIX
Made command into a script but now won't run
patwa
Hello, After seeing in a Unix cheatsheet that I could add commands into a file and run that file as a command to save on typing, i tried it with this: #! /bin/csh # Backup website excluding directories that do not change rsync -e "ssh -p 2222" -axzvc --progress --stats --compress-level=9...... UNIX for Dummies Questions & Answers
9
UNIX for Dummies Questions & Answers
Why won't my script run?
darthur
On the following script that I get an error when I try to execute as root: #./mv_log.sh bash: /root/util/mv_log.sh: Permission denied #!/usr/bin datetag=`date --date='1 day ago' +"%b%d%Y"` logname=`find /opt/bea/wlserver6.1/config/*/logs/ -iname 'access.log0*' -mtime -1 -print` mv...... UNIX for Dummies Questions & Answers
4
UNIX for Dummies Questions & Answers

Featured Tech Videos