The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script through cron and command line rahulrathod UNIX for Dummies Questions & Answers 3 02-22-2008 07:10 AM
Script an Oracle Command Line Blackout pattieatte Shell Programming and Scripting 0 08-30-2007 05:28 PM
script works on command line, not in cron job JackTheTripper UNIX for Dummies Questions & Answers 7 06-27-2007 02:51 AM
Script doesn't work, but commands inside work cheongww UNIX for Dummies Questions & Answers 2 11-14-2006 10:52 PM
Command work but not in SH script cititester UNIX for Dummies Questions & Answers 3 03-06-2006 04:03 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-27-2003
larry larry is offline
Registered User
  
 

Join Date: Nov 2001
Location: Hawaii
Posts: 79
command line work script doesn't

Hello,

I'm stuck and confused as to why when I execute things form the command line it works but when in a script it doesn't.

My script:

### creating a lock on the console
touch /var/run/console.lock
chmod 600 /var/run/console.lock
echo "$User" >> /var/run/console.lock
touch /var/run/console/larry
chmod 600 /var/run/console/larry
echo "1" >>/var/run/console/larry
rm -f /tmp/.X0-lock


### stopping the gnome-login manager
for pid in `ps -ae|grep gdm|awk '{print $1}'|sort -r`
do
kill -9 $pid
done
rm -f /tmp/.X0-lock

### getting the Gnome Desktop Manager
kill -9 `ps -aef|grep gdm|grep X|awk '{print $2}'`

su - larry -c 'exec /bin/sh' <<EOF

xauth list|grep `hostname` >/dev/null
if [ $? -ne 0 ]
then
xauth generate :0 .
fi

#### start the default desktop
/usr/bin/X11/startx& >/dev/null 2>&1

EOF

It does not work but if I rlogin form another machine and run the scipt on the command line (execute each line at the prompt) it works. This is REDHAT 7.2

Thanks
  #2 (permalink)  
Old 08-27-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Do you get any specific errors? Does any part of the script appear to actually execute?
  #3 (permalink)  
Old 08-27-2003
larry larry is offline
Registered User
  
 

Join Date: Nov 2001
Location: Hawaii
Posts: 79
oombra,

Every thing seems to execute with the except when I execut the startx command. As root on the command line things work fine but as root executing the script it doesn't work. I get is:

Fatal server error:
Server is already active for display 0
If this server is no longer running, remove /tmp/.X0-lock and start again.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0