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
Expect Issue Serial Forground Execution vs Concurrent Background Execution twk Shell Programming and Scripting 2 09-14-2009 09:27 PM
Script to carry-over the script execution to another system yuvanash Shell Programming and Scripting 3 05-29-2009 01:51 AM
help on script execution sussane Shell Programming and Scripting 8 01-13-2009 12:22 PM
time of execution of script arghya_owen Shell Programming and Scripting 8 09-03-2008 04:32 AM
pb with script execution Cecile UNIX for Dummies Questions & Answers 3 09-14-2006 11:37 AM

Reply
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 3 Weeks Ago
pinga123 pinga123 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 15
Script Execution Help Needed

Hi guys i have a script (takeconsole) as following
I have moved it to /usr/local/bin to make the execution of script simpler.
below are the content of the file.

When i run the file by typing "takeconsole" .it always ask for entering the IP address but when i run it by using ". takeconsole". it ask for entering the IP address only at first occurrence.


How can establish 2 scenario by just typing "takeconsole" and not ". takeconsole".
Code:
if [ -z "$DISPLAY" ]
then
echo "Please Enter IP address of your machine"
read ipadd
export DISPLAY="$ipadd:0.0"
else
echo display is already set
fi

Last edited by pludi; 3 Weeks Ago at 03:15 AM.. Reason: code tags, please...
  #2 (permalink)  
Old 3 Weeks Ago
pogdorica's Avatar
pogdorica pogdorica is offline
Registered User
  
 

Join Date: Oct 2009
Location: Madrid
Posts: 55
When you run the file with ". takeconsole" , the DISPLAY value is set and the next execution have already the previous value.

With ".", the current shell get the values of the "takeconsole" run (the value is exported).
  #3 (permalink)  
Old 3 Weeks Ago
pinga123 pinga123 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 15
I just want to make the execution simpler how would i establish . takeconsole by just typing takeconsole.
  #4 (permalink)  
Old 3 Weeks Ago
pogdorica's Avatar
pogdorica pogdorica is offline
Registered User
  
 

Join Date: Oct 2009
Location: Madrid
Posts: 55
And ..... can you do a function in .profile file with that code ???

Code:
User Home .profile:
function takeconsole {
   if [ -z "$DISPLAY" ]
   then
      echo "Please Enter IP address of your machine"
      read ipadd
      export DISPLAY="$ipadd:0.0"
    else
      echo display is already set
    fi
}

And then:

    $ takeconsole
  #5 (permalink)  
Old 3 Weeks Ago
pinga123 pinga123 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 15
i dont have much information about .profile and function in .profile .
will it set the DISPLAY globally?
  #6 (permalink)  
Old 3 Weeks Ago
pogdorica's Avatar
pogdorica pogdorica is offline
Registered User
  
 

Join Date: Oct 2009
Location: Madrid
Posts: 55
The value will be set when the user call to 'takeconsole' function from the prompt such as other script.

ok?
Bits Awarded / Charged to pogdorica for this Post
Date User Comment Amount
3 Weeks Ago pinga123 thanks. 5
  #7 (permalink)  
Old 3 Weeks Ago
pinga123 pinga123 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 15
Thanks for the useful suggestion brother.

---------- Post updated at 11:17 PM ---------- Previous update was at 07:39 AM ----------

Quote:
Originally Posted by pogdorica View Post
The value will be set when the user call to 'takeconsole' function from the prompt such as other script.

ok?
How do i modify the script in future.
Reply

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 04:14 AM.


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