LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-10-2010, 11:00 AM   #1
ahmedb72
Member
 
Registered: Jan 2006
Location: Sydney
Distribution: RHEL
Posts: 72

Rep: Reputation: 15
xclock is not running in a script


hi all,

I have created the following script which runs very well when it is executed alone.

This script is to be run by a third party application (Oracle clusterware).

The script (when is run by the application) doesn't successfully execute the xclock command. It even doesn't return the $USER variable.

Following is what I got:
Code:
#
# Copy of the script
#

[oracle@rac1 ~]$ cat /u01/crs/crs/script/crsclock_action.scr
#!/bin/bash
# start/stop/check script for xclock example
#  the script assumes xclock is there
#  and DISPLAY variable is set
APP=/usr/X11R6/bin/xclock
BIN_NAME=xclock

echo `date +"%M:%S"` $0 $* $$>>/tmp/mylog.log

PID1=`ps -ef | grep $BIN_NAME | grep -v grep | grep -v xclock_app | awk '{ print $2 }'`

case $1 in
 'start')
  if [ "$PID1" != "" ]
  then
   status_p1="running"
  else
    if [ -x $APP ]
    then
     ${APP} &
     PID1=`ps -ef | grep $BIN_NAME | grep -v grep | grep -v xclock_app | awk '{ print $2 }'`
     echo `date +"%M:%S"` $* $PID1 $USER>>/tmp/mylog.log
     status_p1="started"
    else
     echo `basename $0`": $APP: Executable not found"
    fi
  fi
  echo "$APP: $status_p1"
  ;;
 'stop')
  if [ "${PID1}" != "" ]
  then
   kill -9 ${PID1} && echo "$APP killed"
  else
   echo "$BIN_NAME: no running Process!"
  fi
  ;;
 'check')
  if [ "$PID1" != "" ]
  then
   echo "running"
   exit 0
  else
   echo "not running"
   echo `date +"%M:%S"` $0 $* "ERR">>/tmp/mylog.log
   exit 1
  fi
  ;;
 *)
  echo "Usage: "`basename $0`" {start|stop|check}"
 ;;
 esac


#
# test output of the script when run alone
#
[oracle@rac1 ~]$ xhost +
access control disabled, clients can connect from any host
[oracle@rac1 ~]$ /u01/crs/crs/script/crsclock_action.scr start
/usr/X11R6/bin/xclock: started
# here I can see the xclock poping up in the screen

[oracle@rac1 ~]$ cat /tmp/mylog.log
44:11 /u01/crs/crs/script/crsclock_action.scr start 17694
44:11 start 17702 oracle

[oracle@rac1 ~]$ /u01/crs/crs/script/crsclock_action.scr check
running

[oracle@rac1 ~]$ cat /tmp/mylog.log

44:11 /u01/crs/crs/script/crsclock_action.scr start 17694
44:11 start 17702 oracle
45:22 /u01/crs/crs/script/crsclock_action.scr check 18270

[oracle@rac1 ~]$ /u01/crs/crs/script/crsclock_action.scr stop
/usr/X11R6/bin/xclock killed


#
# output of log when the script is run by Oracle clusterware
#
#
# log file first is flushed
[oracle@rac1 ~]$ echo ""> /tmp/mylog.log
[oracle@rac1 ~]$ crs_start myClock
Attempting to start `myClock` on member `rac1`
Start of `myClock` on member `rac1` succeeded.
[oracle@rac1 ~]$
[oracle@rac1 ~]$ cat /tmp/mylog.log
48:14 /u01/crs/crs/script/crsclock_action.scr start 19557
48:14 start
48:19 /u01/crs/crs/script/crsclock_action.scr check 19660
48:19 /u01/crs/crs/script/crsclock_action.scr check ERR
48:20 /u01/crs/crs/script/crsclock_action.scr stop 19674
48:20 /u01/crs/crs/script/crsclock_action.scr start 19682
48:20 start
48:25 /u01/crs/crs/script/crsclock_action.scr check 19724
48:25 /u01/crs/crs/script/crsclock_action.scr check ERR
48:25 /u01/crs/crs/script/crsclock_action.scr stop 19733
48:25 /u01/crs/crs/script/crsclock_action.scr start 19741
48:25 start
48:30 /u01/crs/crs/script/crsclock_action.scr check 19783
48:30 /u01/crs/crs/script/crsclock_action.scr check ERR
48:30 /u01/crs/crs/script/crsclock_action.scr stop 19792
Note: the script is automatically re-excuted by Oracle clusterware when the 'check' command returns error and that's why the start 'command' appears multiple times in the log.

Any help is appreciated.
 
Old 01-10-2010, 11:14 AM   #2
c0mpm5tr
LQ Newbie
 
Registered: Feb 2006
Location: Charlotte, NC
Distribution: Slackware
Posts: 9

Rep: Reputation: 1
In the script, you say that you're assuming the DISPLAY variable is set. From what I've seen trying to get things to work with cron, I've always had to explicitly define the DISPLAY variable to get X applications to work when being run automatically from the command line.
DISPLAY=:0.0 usually works (depending on your X server setup)

Last edited by c0mpm5tr; 01-10-2010 at 11:19 AM. Reason: refinements to previous comments
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
xclock - again autophil Programming 1 07-06-2008 10:52 AM
xclock font autophil Linux - Desktop 3 05-27-2007 07:24 AM
xclock autophil Slackware 14 05-26-2007 12:50 AM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 09:10 PM
xclock not running mumtaz52 Linux - Enterprise 3 01-02-2006 12:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration