S.O.S. Mathematics CyberBoard

Your Resource for mathematics help on the web!
It is currently Thu, 23 May 2013 15:49:25 UTC

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: scripting
PostPosted: Tue, 5 Jul 2005 06:14:08 UTC 
Offline
Member of the 'S.O.S. Math' Hall of Fame
User avatar

Joined: Thu, 7 Apr 2005 16:32:15 UTC
Posts: 1276
Location: United States EST
I'm trying to set up a bash script to run GAP with a preloaded workspace. This in itself is not to bad:

Code:
#! \bin\bash
/usr/local/bin/gap -L /usr/local/gap/qgap


However.. I'd like for it to be a little smarter. From a virtual terminal or remote login, I'd like it to use the
/usr/local/gap/qgap_console and from an X session I would like it to load /usr/local/gap/qgap.
Sure I could just make 2 scripts and then have to remember which one to run.. but I'd rather make it choose seemlessly.


Any ideas how to do this? Sure I can set up a conditional.. the tricky part is knowing the right variable to see if I'm in X or not.


-Q


Top
 Profile  
 
 Post subject:
PostPosted: Tue, 5 Jul 2005 07:25:51 UTC 
Check the contents of $DISPLAY, that should work over most all systems. If X is not running, it should be empty. I know $DISPLAY is set using startx, may not be the same if you use something else (why would you though?)

-- X Conrad X


Top
  
 
 Post subject:
PostPosted: Tue, 5 Jul 2005 15:15:55 UTC 
Offline
Member of the 'S.O.S. Math' Hall of Fame
User avatar

Joined: Thu, 7 Apr 2005 16:32:15 UTC
Posts: 1276
Location: United States EST
GOD wrote:
Check the contents of $DISPLAY, that should work over most all systems. If X is not running, it should be empty. I know $DISPLAY is set using startx, may not be the same if you use something else (why would you though?)

-- X Conrad X


Good call. Thanks for the help.
Here is my final script

Code:
#!/bin/bash
FILE="/usr/local/gap4r4/qgap"
[ -z "$DISPLAY" ] && FILE="/usr/local/gap4r4/qgap_console"

/usr/local/gap4r4/bin/gap.sh -L $FILE $*


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Contact Us | S.O.S. Mathematics Homepage
Privacy Statement | Search the "old" CyberBoard

users online during the last hour
Powered by phpBB © 2001, 2005-2011 phpBB Group.
Copyright © 1999-2013 MathMedics, LLC. All rights reserved.
Math Medics, LLC. - P.O. Box 12395 - El Paso TX 79913 - USA