The UNIX and Linux Forums  


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
Setting environment variable on a remote solaris machine using shell script eamani_sun Shell Programming and Scripting 1 05-30-2008 11:05 PM
sed on an environment variable ? lumix Shell Programming and Scripting 3 12-15-2007 06:30 PM
environment variable sharanbr Shell Programming and Scripting 8 06-12-2007 09:43 AM
problem in getting the path of environment variable set in bashrc in my shell script krithika Shell Programming and Scripting 8 05-26-2006 09:19 AM
help on environment variable mehuldoshi UNIX for Advanced & Expert Users 6 03-29-2003 12:45 PM

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 02-12-2007
orno orno is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 21
Set the 'DISPLAY' environment variable script

Hello once again

Im trying to set my DISPLAY variable using a script, so i wrote the following:

Code:
#!/bin/sh
HOME=10.100.1.100
OFFICE1=10.100.1.101
OFFICE2=10.100.1.102

for TEST in HOME OFFICE1 OFFICE2
do
  if [ $1 = $TEST ]
      then
      export DISPLAY=${$TEST}
      break
  else
      echo "Not Matched"
  fi
done
I expect to use this script to say something like: setdisplay HOME and then it sets my DISPLAY variable to 10.100.1.100, so when I launch some X processes, it displays on my computer at home

There is obviously something wrong with the way I'm implementing the $($...)) part, except I don't know what. Is there any proper way to do this?

Also, if someone has any recommendations on how to implement what I want in a more efficient way, by all means, enlighten me

Thanks!
  #2 (permalink)  
Old 02-12-2007
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
Try this:
Code:
#!/bin/sh
case $1 in
HOME)      export DISPLAY=10.100.1.100
;;
OFFICE1)   export DISPLAY=10.100.1.101
;;
OFFICE2)   export DISPLAY=10.100.1.102
;;
*)         echo "Not Matched"
esac
In your script, yeah value assignment was wrong, you can try export DISPLAY=${TEST} or export DISPLAY=$TEST

Regards,
Tayyab
  #3 (permalink)  
Old 02-12-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
try this
Code:
#!/bin/sh
HOME=10.100.1.100
OFFICE1=10.100.1.101
OFFICE2=10.100.1.102

for TEST in \$HOME \$OFFICE1 \$OFFICE2
do
  if [ $1 = $TEST ]
      then
      export DISPLAY=$(eval echo $TEST)
      break
  else
      echo "Not Matched"
  fi
done
  #4 (permalink)  
Old 02-12-2007
orno orno is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 21
aha
great

so thats how u use eval

thanks for the help guys!
Closed Thread

Bookmarks

Tags
export display

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 07:51 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