D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] shell script



Hi

I am writing a shell script to run doom legacy from my home directory, it's 
stored under /opt/legacy1.32beta4

the script is as follows

#/bin/bash
pwd > pwd1
cd /opt/legacy-1.32beta4
./llxdoom

echo exiting game
cd < pwd1

If I run in a console I get the message error (DISPLAY=[(NULL)])
If I run in xterm it works,(as it uses the xdisplay)  how do I test if the 
user is running a console or xterm, and print say "please run in xterm" or 
something.  I have attempted this with the if to fi statements  see below 
.however I think my pwd > pwd1 is getting in the way (the idea is to save the 
current path to a file then when the game exits go back to the user home 
directory

if I use 

#/bin/bash
/opt/legacy-1.32beta4/llxdoom 

it looks for the wad files in the users home directory,  so I figured the cd 
command was a way round this,  But somehow feel its the wrong way to go about 
things,  

I also keep getting file not found for pwd1 which is odd as it's there and 
created by the script at the start,  I think I am on the right track 
somewhere but just a bit stuck,  I am still looking through the book,  SAMS 
TY shell programming in 24 hrs. 

as mentioned above I have tried the following where I put the space above (the 
space is not in the actual script I just moved this bit to write the e-mail),  

if [ $? -eq 0 ];then
: # cmd " sucessful "
else
: # cmd " failed "
fi


It's on page 406 of the book I don't really follow what the : # is doing 
the other script on the page is

grep soda /etc/hosts > dev/nulll 2>&1
if [ $? -ne 0 ] ; then
echo "soda found"
else 
echo "No entry in /etc/hosts for soda."
fi

which seems better as it looks at the output file,   
which I under stand better but am unsure how to apply this to the above 
script.  I guess I need to redirect output to a file,  and then get grep to 
look for (DISPLAY=[(NULL)])

I tried this but got syntax error,  

I would be grateful for any pointers,  or suggestions 

thanks 

Paul



--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly