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".
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
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).
I just want to make the execution simpler how would i establish . takeconsole by just typing takeconsole.
And ..... can you do a function in .profile file with that 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
i dont have much information about .profile and function in .profile .
will it set the DISPLAY globally?
The value will be set when the user call to 'takeconsole' function from the prompt such as other script.
ok?
Thanks for the useful suggestion brother.
---------- Post updated at 11:17 PM ---------- Previous update was at 07:39 AM ----------
How do i modify the script in future.
Hi.
You only will must to modify the .profile script and "re-login".
Where would i find .profile file to modify.Please explain .
Hi.
You must to add the function of the previous post in the user home .profile.