. myprofile

How can I get the name and dir of myprofile file that I have dotted ?

Example:
/tmp/myprofile whose content is:
Me=Take_this_filename
Mydir=Take_the_dir_where_this_file_lives


Executing ( Dot . followed by a space + filename )
. /tmp/myprofile or . myprofile The var $Me should
provide the name of the file. ie. myprofile !
and $Mydir
the value /tmp/myprofile

Any ideas ?

Thank you,
Carlos
carlos.juvenal [ Di, 08 April 2008 12:36 ] [ ID #1937607 ]

Re: . myprofile

carlos.juvenal [at] gmail.com writes:

> How can I get the name and dir of myprofile file that I have dotted ?

It's hard to do this in general. Consider
cat /tmp/myprofile | sh -
where is the file located?

Here's one solution: Put it in when you create myprofile.

file=myprofile
dir=/tmp
echo Me=$file >$dir/$file
echo Mydir=$dir >>$dir/$file
cat rest_of_myprofile >> $dir/$file

The other way is to change the script. If you have a script that
KNOWS the filename, and READS the file, then there is the perfect
place to determine the information you want.
Maxwell Lol [ Di, 08 April 2008 19:00 ] [ ID #1937621 ]
Linux » comp.unix.shell » . myprofile

Vorheriges Thema: I Need help in C Script in unix enviroment
Nächstes Thema: how to get messages originally output to stderr after it has been