Visit Our UNIX and Linux User Community

command line work script doesn't

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting command line work script doesn't
# 1  
Old 08-27-2003
command line work script doesn't


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`
kill -9 $pid
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 ]
xauth generate :0 .

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


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

# 2  
Old 08-27-2003
Do you get any specific errors? Does any part of the script appear to actually execute?
# 3  
Old 08-27-2003

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.

Previous Thread | Next Thread
Test Your Knowledge in Computers #312
Difficulty: Easy
Linus Torvalds created Unix and Git.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

7z command for files larger than 4GB ( unzip doesn't work)

My unzip command doesn't work for files that are greater than 4GB. Consider my file name is unzip -p -a, the command doesn't work since the size of the file is larger. I need to know the corresponding 7z command for the same. This is my Unix shell script program: if then ... (14 Replies)
Discussion started by: chandraprakash
14 Replies

2. Shell Programming and Scripting

Ssh remote command doesn't work from script file

I have 10 application servers in a distributed architecture generating their own application logs. Each server has application utility to continuously tail the log. for example following command follows tails and follows new logfiles as they are generated server1$ logutility logtype When I run... (8 Replies)
Discussion started by: indianya
8 Replies

3. Solaris

Mount command doesn't work on Solaris System

Hi All, I am using a solaris Sun-Fire-V440 server. The OS is solaris. My problem is whenever I run the command mount | grep "^/ " | sed -e 's,^.*dsk/\(*\).*$,\1,' it should return a disk value as "d30" as it does on each of my other servers.But on this server I am not getting any o/p from... (3 Replies)
Discussion started by: vivek.goel.piet
3 Replies

4. Shell Programming and Scripting

sed command works on Fedora/Ubuntu, but doesn't work in Mac

Hi, I have a question. I define a function using sed command: replace() { searchterm=$1 replaceterm=$2 sed -e "s/$searchterm/$replaceterm/ig" $3 > $WORK'tempfile.tmp' mv $WORK'tempfile.tmp' $3 } Then I call replace 'test = 0' 'test = 1' $myfileThis code works well in... (1 Reply)
Discussion started by: Dark2Bright
1 Replies

5. UNIX for Dummies Questions & Answers

find command in shell script doesn't work

Hello all, Something strange going on with a shell script I'm writing. It's trying to write a list of files that it finds in a given directory to another file. But I also have a skip list so matching files that are in that skip list should be, well uhm, skipped :) Here's the code of my... (2 Replies)
Discussion started by: StijnV
2 Replies

6. Shell Programming and Scripting

my script doesn't work :(

i have this script and when i ejecute it, the console tell me this " sintax error line 41 unexpected element "}" " is the sintaxis ok? #!/bin/bash if ;then { exit 0; } if ; then { sudo /etc/init.d/apache2 start; sudo /etc/init.d/mysql start; php5 & nautilus... (3 Replies)
Discussion started by: keiserx
3 Replies

7. Shell Programming and Scripting

Help with script.. it Just doesn't work

Hello,, Im verry new to scripting and have some problems with this script i made.. What it does: It checks a directory for a new directory and then issues a couple of commands. checks sfv - not doing right now checks rar - it checks if theres a rar file and when there is it skips to... (1 Reply)
Discussion started by: atmosroll
1 Replies

8. Shell Programming and Scripting

cd command doesn't work through variables

Hi.... cd command is not working when dual string drive/volume name is passed to cd through variables....... For Ex.... y=/Volumes/Backup\ vipin/ cd $y the above command gives error....... anyone with a genuine solution ? (16 Replies)
Discussion started by: vipinchauhan222
16 Replies

9. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

10. Shell Programming and Scripting

Command doesn't work under cron ?

I have defined in cron crontab -l >/FIXENGINE/data/crontab.$(whoami).$(date +%a) The resulting file is named crontab.fixadmin. When I run the above from a command line, the file is named: crontab.fixadmin.Tue (or whatever day I happen to be running) The question is - why do I get... (4 Replies)
Discussion started by: bigjohn-nj
4 Replies

Featured Tech Videos